[poppler] Branch 'xpdf303merge' - cpp/poppler-document.cpp cpp/poppler-private.cpp cpp/poppler-private.h qt4/src test/perf-test.cc
Albert Astals Cid
aacid at kemper.freedesktop.org
Wed Aug 31 10:13:58 PDT 2011
cpp/poppler-document.cpp | 2 +-
cpp/poppler-private.cpp | 6 ++----
cpp/poppler-private.h | 3 ++-
qt4/src/poppler-private.cc | 8 +++-----
test/perf-test.cc | 4 ++--
5 files changed, 10 insertions(+), 13 deletions(-)
New commits:
commit 53f94df2ce21793914ccc153ba6b2fe5cbeb8371
Author: Albert Astals Cid <aacid at kde.org>
Date: Wed Aug 31 19:17:13 2011 +0200
Port to setErrorCallback
diff --git a/cpp/poppler-document.cpp b/cpp/poppler-document.cpp
index 4cf7ec0..1c24b47 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 2fc7d92..2783bed 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 0aca69e..a4b455c 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 af1f4e4..ffb5b92 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 6dc8e34..45961d3 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);
More information about the poppler
mailing list