summaryrefslogtreecommitdiff
path: root/qt4
diff options
context:
space:
mode:
authorPino Toscano <pino@kde.org>2010-11-11 21:52:25 +0100
committerPino Toscano <pino@kde.org>2010-11-11 21:52:25 +0100
commitd772364b8a5858cbd98e256547d319260fa9d084 (patch)
tree9f38e0e35e08ce2a2b1b27db2097f85f744afa3a /qt4
parentce929cf33f4b6b6421f9d327b4bb792816d47aac (diff)
[Qt4] New function setDebugErrorFunction().
This new function + typedef can be useful to direct the ebug/error messages to a different place than the default qDebug()'s one. Base on an idea of Albert, added closure and polish by me.
Diffstat (limited to 'qt4')
-rw-r--r--qt4/src/poppler-private.cc20
-rw-r--r--qt4/src/poppler-qt4.h24
2 files changed, 43 insertions, 1 deletions
diff --git a/qt4/src/poppler-private.cc b/qt4/src/poppler-private.cc
index 1cbcc91e..3c30ff23 100644
--- a/qt4/src/poppler-private.cc
+++ b/qt4/src/poppler-private.cc
@@ -32,6 +32,24 @@
namespace Poppler {
+namespace Debug {
+
+ void qDebugDebugFunction(const QString &message, const QVariant & /*closure*/)
+ {
+ qDebug() << message;
+ }
+
+ PopplerDebugFunc debugFunction = qDebugDebugFunction;
+ QVariant debugClosure;
+
+}
+
+ void setDebugErrorFunction(PopplerDebugFunc function, const QVariant &closure)
+ {
+ Debug::debugFunction = function ? function : Debug::qDebugDebugFunction;
+ Debug::debugClosure = closure;
+ }
+
void qt4ErrorFunction(int pos, char *msg, va_list args)
{
QString emsg;
@@ -47,7 +65,7 @@ namespace Poppler {
}
qvsnprintf(buffer, sizeof(buffer) - 1, msg, args);
emsg += QString::fromAscii(buffer);
- qDebug() << qPrintable(emsg);
+ (*Debug::debugFunction)(emsg, Debug::debugClosure);
}
QString unicodeToQString(Unicode* u, int len) {
diff --git a/qt4/src/poppler-qt4.h b/qt4/src/poppler-qt4.h
index c50e4f9f..576c53e1 100644
--- a/qt4/src/poppler-qt4.h
+++ b/qt4/src/poppler-qt4.h
@@ -59,6 +59,30 @@ namespace Poppler {
class PSConverter;
/**
+ Debug/error function.
+
+ This function type is used for debugging & error output;
+ the first parameter is the actual message, the second is the unaltered
+ closure argument which was passed to the setDebugErrorFunction call.
+
+ \since 0.16
+ */
+ typedef void (*PopplerDebugFunc)(const QString & /*message*/, const QVariant & /*closure*/);
+
+ /**
+ Set a new debug/error output function.
+
+ If not set, by default error and debug messages will be sent to the
+ Qt \p qDebug() function.
+
+ \param debugFunction the new debug function
+ \param closure user data which will be passes as-is to the debug function
+
+ \since 0.16
+ */
+ POPPLER_QT4_EXPORT void setDebugErrorFunction(PopplerDebugFunc debugFunction, const QVariant &closure);
+
+ /**
Describes the physical location of text on a document page
This very simple class describes the physical location of text