Commit 53f94df2 authored by Albert Astals Cid's avatar Albert Astals Cid

Port to setErrorCallback

parent 95a52f06
......@@ -43,7 +43,7 @@ initer::initer()
{
if (!count) {
globalParams = new GlobalParams();
setErrorFunction(detail::error_function);
setErrorCallback(detail::error_function, NULL);
}
count++;
}
......
......@@ -28,7 +28,7 @@
using namespace poppler;
void detail::error_function(int pos, const char *msg, va_list args)
void detail::error_function(void * /*data*/, ErrorCategory /*category*/, int pos, char *msg)
{
std::ostringstream oss;
if (pos >= 0) {
......@@ -36,9 +36,7 @@ void detail::error_function(int pos, const char *msg, va_list args)
} else {
oss << "poppler/error: ";
}
char buffer[4096]; // should be big enough
vsnprintf(buffer, sizeof(buffer) - 1, msg, args);
oss << buffer;
oss << msg;
std::cerr << oss.str();
}
......
......@@ -22,6 +22,7 @@
#include "poppler-global.h"
#include "poppler-rectangle.h"
#include "Error.h"
#include "CharTypes.h"
#include <stdarg.h>
......@@ -37,7 +38,7 @@ namespace poppler
namespace detail
{
void error_function(int pos, const char *msg, va_list args);
void error_function(void *data, ErrorCategory category, int pos, char *msg);
rectf pdfrectangle_to_rectf(const PDFRectangle &pdfrect);
......
......@@ -53,10 +53,9 @@ namespace Debug {
Debug::debugClosure = closure;
}
void qt4ErrorFunction(int pos, const char *msg, va_list args)
void qt4ErrorFunction(void * /*data*/, ErrorCategory /*category*/, int pos, char *msg)
{
QString emsg;
char buffer[1024]; // should be big enough
if (pos >= 0)
{
......@@ -66,8 +65,7 @@ namespace Debug {
{
emsg = QString::fromLatin1("Error: ");
}
qvsnprintf(buffer, sizeof(buffer) - 1, msg, args);
emsg += QString::fromAscii(buffer);
emsg += QString::fromAscii(msg);
(*Debug::debugFunction)(emsg, Debug::debugClosure);
}
......@@ -252,7 +250,7 @@ namespace Debug {
{
utf8Map = 0;
globalParams = new GlobalParams();
setErrorFunction(qt4ErrorFunction);
setErrorCallback(qt4ErrorFunction, NULL);
}
count ++;
}
......
......@@ -742,7 +742,7 @@ void OutputDebugString(const char *txt)
#define _vsnprintf vsnprintf
#endif
void my_error(int pos, const char *msg, va_list args) {
void my_error(void *, ErrorCategory, int pos, char *msg) {
#if 0
char buf[4096], *p = buf;
......@@ -1231,7 +1231,7 @@ static void RenderCmdLineArg(char *cmdLineArg)
int main(int argc, char **argv)
{
setErrorFunction(my_error);
setErrorCallback(my_error, NULL);
ParseCommandLine(argc, argv);
if (0 == StrList_Len(&gArgsListRoot))
PrintUsageAndExit(argc, argv);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment