qt4/src/poppler-private.cc |   20 +++++++++++++++++++-
 qt4/src/poppler-qt4.h      |   24 ++++++++++++++++++++++++
 2 files changed, 43 insertions(+), 1 deletion(-)

New commits:
commit d772364b8a5858cbd98e256547d319260fa9d084
Author: Pino Toscano <[email protected]>
Date:   Thu Nov 11 21:52:25 2010 +0100

    [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.

diff --git a/qt4/src/poppler-private.cc b/qt4/src/poppler-private.cc
index 1cbcc91..3c30ff2 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 c50e4f9..576c53e 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
_______________________________________________
poppler mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/poppler

Reply via email to