summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlbert Astals Cid <aacid@kde.org>2011-08-31 19:17:13 +0200
committerAlbert Astals Cid <aacid@kde.org>2011-08-31 19:17:13 +0200
commit53f94df2ce21793914ccc153ba6b2fe5cbeb8371 (patch)
tree38a40a8e4f989251a1f2713219fac0a07446d496
parent95a52f06a98f49f7c8f2b92634b75af96b4eee1d (diff)
Port to setErrorCallback
-rw-r--r--cpp/poppler-document.cpp2
-rw-r--r--cpp/poppler-private.cpp6
-rw-r--r--cpp/poppler-private.h3
-rw-r--r--qt4/src/poppler-private.cc8
-rw-r--r--test/perf-test.cc4
5 files changed, 10 insertions, 13 deletions
diff --git a/cpp/poppler-document.cpp b/cpp/poppler-document.cpp
index 4cf7ec05..1c24b476 100644
--- a/cpp/poppler-document.cpp
+++ b/cpp/poppler-document.cpp
@@ -43,7 +43,7 @@ initer::initer()
{
if (!count) {
globalParams = new GlobalParams();
- setErrorFunction(detail::error_function);
+ setErrorCallback(detail::error_function, NULL);
}
count++;
}
diff --git a/cpp/poppler-private.cpp b/cpp/poppler-private.cpp
index 2fc7d92c..2783bed4 100644
--- a/cpp/poppler-private.cpp
+++ b/cpp/poppler-private.cpp
@@ -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();
}
diff --git a/cpp/poppler-private.h b/cpp/poppler-private.h
index 0aca69e5..a4b455c4 100644
--- a/cpp/poppler-private.h
+++ b/cpp/poppler-private.h
@@ -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);
diff --git a/qt4/src/poppler-private.cc b/qt4/src/poppler-private.cc
index af1f4e49..ffb5b92b 100644
--- a/qt4/src/poppler-private.cc
+++ b/qt4/src/poppler-private.cc
@@ -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 ++;
}
diff --git a/test/perf-test.cc b/test/perf-test.cc
index 6dc8e341..45961d31 100644
--- a/test/perf-test.cc
+++ b/test/perf-test.cc
@@ -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);