Changed debug output to option in qminimalbackingstore.
authorKurt Korbatits <kurt.korbatits@nokia.com>
Mon, 23 Jan 2012 00:35:19 +0000 (10:35 +1000)
committerQt by Nokia <qt-info@nokia.com>
Tue, 31 Jan 2012 03:55:05 +0000 (04:55 +0100)
- Added QT_DEBUG_BACKINGSTORE environment variable to enable
  debug output. Defaulting to no output if not set.

Change-Id: Id9c369031f946d77605321c8b28ab3378da8fbf9
Reviewed-by: Kurt Korbatits <kurt.korbatits@nokia.com>
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
Reviewed-by: Jonas Gastal <jgastal@profusion.mobi>
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
src/plugins/platforms/minimal/qminimalbackingstore.cpp
src/plugins/platforms/minimal/qminimalbackingstore.h

index eca81c2..b6b9c0e 100644 (file)
 QT_BEGIN_NAMESPACE
 
 QMinimalBackingStore::QMinimalBackingStore(QWindow *window)
-    : QPlatformBackingStore(window)
+    : QPlatformBackingStore(window),mDebug(false)
 {
-    //qDebug() << "QMinimalBackingStore::QMinimalBackingStore:" << (long)this;
+    if (QT_PREPEND_NAMESPACE(qgetenv)("QT_DEBUG_BACKINGSTORE").toInt() > 0)
+        mDebug = true;
+    if (mDebug)
+        qDebug() << "QMinimalBackingStore::QMinimalBackingStore:" << (long)this;
 }
 
 QMinimalBackingStore::~QMinimalBackingStore()
@@ -59,7 +62,9 @@ QMinimalBackingStore::~QMinimalBackingStore()
 
 QPaintDevice *QMinimalBackingStore::paintDevice()
 {
-    //qDebug() << "QMinimalBackingStore::paintDevice";
+    if (mDebug)
+        qDebug() << "QMinimalBackingStore::paintDevice";
+
     return &mImage;
 }
 
@@ -69,15 +74,16 @@ void QMinimalBackingStore::flush(QWindow *window, const QRegion &region, const Q
     Q_UNUSED(region);
     Q_UNUSED(offset);
 
-    static int c = 0;
-    QString filename = QString("output%1.png").arg(c++, 4, 10, QLatin1Char('0'));
-    qDebug() << "QMinimalBackingStore::flush() saving contents to" << filename.toLocal8Bit().constData();
-    mImage.save(filename);
+    if (mDebug) {
+        static int c = 0;
+        QString filename = QString("output%1.png").arg(c++, 4, 10, QLatin1Char('0'));
+        qDebug() << "QMinimalBackingStore::flush() saving contents to" << filename.toLocal8Bit().constData();
+        mImage.save(filename);
+    }
 }
 
 void QMinimalBackingStore::resize(const QSize &size, const QRegion &)
 {
-    //qDebug() << "QMinimalBackingStore::setGeometry:" << (long)this << rect;
     QImage::Format format = QGuiApplication::primaryScreen()->handle()->format();
     if (mImage.size() != size)
         mImage = QImage(size, format);
index 9969a93..375edaa 100644 (file)
@@ -60,6 +60,7 @@ public:
 
 private:
     QImage mImage;
+    bool mDebug;
 };
 
 QT_END_NAMESPACE