From 69032adda0bf10bb51a44bbfc87752608a5f86a6 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 23 Oct 2015 10:53:15 +0200 Subject: Windows QPA: Fix debug operators. Enclose all debug operators within QT_NO_DEBUG_STREAM, declare all public ones and make the others static. Add operators for POINT and WINDOWPLACEMENT. Task-number: QTBUG-48449 Change-Id: I33f2dba2bf486a8f5cb11f11f4e2b37cce086def Reviewed-by: Joerg Bornemann --- .../platforms/windows/qwindowsclipboard.cpp | 2 + .../platforms/windows/qwindowsdialoghelpers.cpp | 2 + src/plugins/platforms/windows/qwindowsdrag.cpp | 6 +-- .../platforms/windows/qwindowsfontdatabase.cpp | 2 + .../platforms/windows/qwindowsfontdatabase.h | 4 ++ .../platforms/windows/qwindowsfontdatabase_ft.cpp | 2 +- .../platforms/windows/qwindowsglcontext.cpp | 52 +++++++++++----------- src/plugins/platforms/windows/qwindowsglcontext.h | 6 ++- src/plugins/platforms/windows/qwindowsmime.cpp | 4 +- src/plugins/platforms/windows/qwindowsmime.h | 2 +- .../platforms/windows/qwindowsopengltester.cpp | 2 + .../platforms/windows/qwindowsopengltester.h | 2 + src/plugins/platforms/windows/qwindowsscreen.cpp | 2 + .../platforms/windows/qwindowstabletsupport.cpp | 4 ++ .../platforms/windows/qwindowstabletsupport.h | 2 + src/plugins/platforms/windows/qwindowswindow.cpp | 48 +++++++++++++------- src/plugins/platforms/windows/qwindowswindow.h | 9 ++-- 17 files changed, 98 insertions(+), 53 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/windows/qwindowsclipboard.cpp b/src/plugins/platforms/windows/qwindowsclipboard.cpp index 97459a4d97..8936b96b1f 100644 --- a/src/plugins/platforms/windows/qwindowsclipboard.cpp +++ b/src/plugins/platforms/windows/qwindowsclipboard.cpp @@ -69,6 +69,7 @@ static const char formatTextHtmlC[] = "text/html"; \ingroup qt-lighthouse-win */ +#ifndef QT_NO_DEBUG_STREAM static QDebug operator<<(QDebug d, const QMimeData *mimeData) { QDebugStateSaver saver(d); @@ -93,6 +94,7 @@ static QDebug operator<<(QDebug d, const QMimeData *mimeData) d << ')'; return d; } +#endif // !QT_NO_DEBUG_STREAM /*! \class QWindowsClipboardRetrievalMimeData diff --git a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp index da0ba27e3a..b983ba3354 100644 --- a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp +++ b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp @@ -360,6 +360,7 @@ public: QT_BEGIN_NAMESPACE +#ifndef QT_NO_DEBUG_STREAM /* Output UID (IID, CLSID) as C++ constants. * The constants are contained in the Windows SDK libs, but not for MinGW. */ static inline QString guidToString(const GUID &g) @@ -385,6 +386,7 @@ inline QDebug operator<<(QDebug d, const GUID &g) d << guidToString(g); return d; } +#endif // !QT_NO_DEBUG_STREAM // Return an allocated wchar_t array from a QString, reserve more memory if desired. static wchar_t *qStringToWCharArray(const QString &s, size_t reserveSize = 0) diff --git a/src/plugins/platforms/windows/qwindowsdrag.cpp b/src/plugins/platforms/windows/qwindowsdrag.cpp index d24cba3c68..870e7fec07 100644 --- a/src/plugins/platforms/windows/qwindowsdrag.cpp +++ b/src/plugins/platforms/windows/qwindowsdrag.cpp @@ -249,7 +249,7 @@ private: QWindowsDragCursorWindow *m_touchDragWindow; ULONG m_refs; -#ifndef QT_NO_DEBUG_OUTPUT +#ifndef QT_NO_DEBUG_STREAM friend QDebug operator<<(QDebug, const QWindowsOleDropSource::CursorEntry &); #endif }; @@ -271,14 +271,14 @@ QWindowsOleDropSource::~QWindowsOleDropSource() qCDebug(lcQpaMime) << __FUNCTION__; } -#ifndef QT_NO_DEBUG_OUTPUT +#ifndef QT_NO_DEBUG_STREAM QDebug operator<<(QDebug d, const QWindowsOleDropSource::CursorEntry &e) { d << "CursorEntry:" << e.pixmap.size() << '#' << e.cacheKey << "HCURSOR" << e.cursor->cursor << "hotspot:" << e.hotSpot; return d; } -#endif // !QT_NO_DEBUG_OUTPUT +#endif // !QT_NO_DEBUG_STREAM static qreal dragScaleFactor() { diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp index 3b27964b0e..9531d30e06 100644 --- a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp +++ b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp @@ -606,6 +606,7 @@ static inline bool initDirectWrite(QWindowsFontEngineData *d) \ingroup qt-lighthouse-win */ +#ifndef QT_NO_DEBUG_STREAM QDebug operator<<(QDebug d, const QFontDef &def) { QDebugStateSaver saver(d); @@ -617,6 +618,7 @@ QDebug operator<<(QDebug d, const QFontDef &def) << def.hintingPreference; return d; } +#endif // !QT_NO_DEBUG_STREAM static inline QFontDatabase::WritingSystem writingSystemFromCharSet(uchar charSet) { diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase.h b/src/plugins/platforms/windows/qwindowsfontdatabase.h index efb5421996..10b6315aab 100644 --- a/src/plugins/platforms/windows/qwindowsfontdatabase.h +++ b/src/plugins/platforms/windows/qwindowsfontdatabase.h @@ -118,6 +118,10 @@ private: QMap m_uniqueFontData; }; +#ifndef QT_NO_DEBUG_STREAM +QDebug operator<<(QDebug, const QFontDef &def); +#endif + QT_END_NAMESPACE #endif // QWINDOWSFONTDATABASE_H diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp b/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp index 795554698c..16cc2afef6 100644 --- a/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp +++ b/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp @@ -355,7 +355,7 @@ static bool addFontToDatabase(const QString &faceName, const QFont::Weight weight = QPlatformFontDatabase::weightFromInteger(tm->tmWeight); const QFont::Stretch stretch = QFont::Unstretched; -#ifndef QT_NO_DEBUG_OUTPUT +#ifndef QT_NO_DEBUG_STREAM if (QWindowsContext::verbose > 2) { QString message; QTextStream str(&message); diff --git a/src/plugins/platforms/windows/qwindowsglcontext.cpp b/src/plugins/platforms/windows/qwindowsglcontext.cpp index e372acc747..a06707b84c 100644 --- a/src/plugins/platforms/windows/qwindowsglcontext.cpp +++ b/src/plugins/platforms/windows/qwindowsglcontext.cpp @@ -284,6 +284,7 @@ static inline void initPixelFormatDescriptor(PIXELFORMATDESCRIPTOR *d) d->nVersion = 1; } +#ifndef QT_NO_DEBUG_STREAM QDebug operator<<(QDebug d, const PIXELFORMATDESCRIPTOR &pd) { QDebugStateSaver saver(d); @@ -326,6 +327,32 @@ QDebug operator<<(QDebug d, const PIXELFORMATDESCRIPTOR &pd) return d; } +QDebug operator<<(QDebug d, const QOpenGLStaticContext &s) +{ + QDebugStateSaver saver(d); + d.nospace(); + d << "OpenGL: " << s.vendor << ',' << s.renderer << " default " + << s.defaultFormat; + if (s.extensions & QOpenGLStaticContext::SampleBuffers) + d << ",SampleBuffers"; + if (s.hasExtensions()) + d << ", Extension-API present"; + d << "\nExtensions: " << (s.extensionNames.count(' ') + 1); + if (QWindowsContext::verbose > 1) + d << s.extensionNames; + return d; +} + +QDebug operator<<(QDebug d, const QWindowsOpenGLContextFormat &f) +{ + QDebugStateSaver saver(d); + d.nospace(); + d << "ContextFormat: v" << (f.version >> 8) << '.' << (f.version & 0xFF) + << " profile: " << f.profile << " options: " << f.options; + return d; +} +#endif // !QT_NO_DEBUG_STREAM + // Check whether an obtained PIXELFORMATDESCRIPTOR matches the request. static inline bool isAcceptableFormat(const QWindowsOpenGLAdditionalFormat &additional, @@ -900,15 +927,6 @@ void QWindowsOpenGLContextFormat::apply(QSurfaceFormat *format) const format->setOption(QSurfaceFormat::DeprecatedFunctions); } -QDebug operator<<(QDebug d, const QWindowsOpenGLContextFormat &f) -{ - QDebugStateSaver saver(d); - d.nospace(); - d << "ContextFormat: v" << (f.version >> 8) << '.' << (f.version & 0xFF) - << " profile: " << f.profile << " options: " << f.options; - return d; -} - /*! \class QOpenGLTemporaryContext \brief A temporary context that can be instantiated on the stack. @@ -1013,22 +1031,6 @@ QOpenGLStaticContext *QOpenGLStaticContext::create(bool softwareRendering) return result; } -QDebug operator<<(QDebug d, const QOpenGLStaticContext &s) -{ - QDebugStateSaver saver(d); - d.nospace(); - d << "OpenGL: " << s.vendor << ',' << s.renderer << " default " - << s.defaultFormat; - if (s.extensions & QOpenGLStaticContext::SampleBuffers) - d << ",SampleBuffers"; - if (s.hasExtensions()) - d << ", Extension-API present"; - d << "\nExtensions: " << (s.extensionNames.count(' ') + 1); - if (QWindowsContext::verbose > 1) - d << s.extensionNames; - return d; -} - /*! \class QWindowsGLContext \brief Open GL context. diff --git a/src/plugins/platforms/windows/qwindowsglcontext.h b/src/plugins/platforms/windows/qwindowsglcontext.h index 516fa0707e..ba617f13ce 100644 --- a/src/plugins/platforms/windows/qwindowsglcontext.h +++ b/src/plugins/platforms/windows/qwindowsglcontext.h @@ -85,7 +85,11 @@ struct QWindowsOpenGLContextFormat QSurfaceFormat::FormatOptions options; }; +#ifndef QT_NO_DEBUG_STREAM +QDebug operator<<(QDebug d, const PIXELFORMATDESCRIPTOR &); QDebug operator<<(QDebug d, const QWindowsOpenGLContextFormat &); +QDebug operator<<(QDebug d, const QOpenGLStaticContext &s); +#endif struct QWindowsOpengl32DLL { @@ -224,8 +228,6 @@ public: static QWindowsOpengl32DLL opengl32; }; -QDebug operator<<(QDebug d, const QOpenGLStaticContext &); - class QWindowsGLContext : public QWindowsOpenGLContext { public: diff --git a/src/plugins/platforms/windows/qwindowsmime.cpp b/src/plugins/platforms/windows/qwindowsmime.cpp index 52a4ca26dc..0a2ba9b0e7 100644 --- a/src/plugins/platforms/windows/qwindowsmime.cpp +++ b/src/plugins/platforms/windows/qwindowsmime.cpp @@ -378,7 +378,7 @@ static bool canGetData(int cf, IDataObject * pDataObj) return true; } -#ifndef QT_NO_DEBUG_OUTPUT +#ifndef QT_NO_DEBUG_STREAM QDebug operator<<(QDebug d, const FORMATETC &tc) { QDebugStateSaver saver(d); @@ -443,7 +443,7 @@ QDebug operator<<(QDebug d, IDataObject *dataObj) d << ')'; return d; } -#endif // !QT_NO_DEBUG_OUTPUT +#endif // !QT_NO_DEBUG_STREAM /*! \class QWindowsMime diff --git a/src/plugins/platforms/windows/qwindowsmime.h b/src/plugins/platforms/windows/qwindowsmime.h index 17fddef1bc..1ec0dccdf8 100644 --- a/src/plugins/platforms/windows/qwindowsmime.h +++ b/src/plugins/platforms/windows/qwindowsmime.h @@ -93,7 +93,7 @@ private: mutable int m_internalMimeCount; }; -#ifndef QT_NO_DEBUG_OUTPUT +#ifndef QT_NO_DEBUG_STREAM QDebug operator<<(QDebug, const FORMATETC &); QDebug operator<<(QDebug d, IDataObject *); #endif diff --git a/src/plugins/platforms/windows/qwindowsopengltester.cpp b/src/plugins/platforms/windows/qwindowsopengltester.cpp index befd06f1a2..e32a7e32af 100644 --- a/src/plugins/platforms/windows/qwindowsopengltester.cpp +++ b/src/plugins/platforms/windows/qwindowsopengltester.cpp @@ -98,6 +98,7 @@ GpuDescription GpuDescription::detect() #endif } +#ifndef QT_NO_DEBUG_STREAM QDebug operator<<(QDebug d, const GpuDescription &gd) { QDebugStateSaver s(d); @@ -109,6 +110,7 @@ QDebug operator<<(QDebug d, const GpuDescription &gd) << ", version=" << gd.driverVersion << ", " << gd.description << ')'; return d; } +#endif // !QT_NO_DEBUG_STREAM // Return printable string formatted like the output of the dxdiag tool. QString GpuDescription::toString() const diff --git a/src/plugins/platforms/windows/qwindowsopengltester.h b/src/plugins/platforms/windows/qwindowsopengltester.h index 3cd8bf4d4b..f22031aa4e 100644 --- a/src/plugins/platforms/windows/qwindowsopengltester.h +++ b/src/plugins/platforms/windows/qwindowsopengltester.h @@ -60,7 +60,9 @@ struct GpuDescription QByteArray description; }; +#ifndef QT_NO_DEBUG_STREAM QDebug operator<<(QDebug d, const GpuDescription &gd); +#endif class QWindowsOpenGLTester { diff --git a/src/plugins/platforms/windows/qwindowsscreen.cpp b/src/plugins/platforms/windows/qwindowsscreen.cpp index e6abfb2403..c603b2bd09 100644 --- a/src/plugins/platforms/windows/qwindowsscreen.cpp +++ b/src/plugins/platforms/windows/qwindowsscreen.cpp @@ -172,6 +172,7 @@ static inline WindowsScreenDataList monitorData() return result; } +#ifndef QT_NO_DEBUG_STREAM static QDebug operator<<(QDebug dbg, const QWindowsScreenData &d) { QDebugStateSaver saver(dbg); @@ -192,6 +193,7 @@ static QDebug operator<<(QDebug dbg, const QWindowsScreenData &d) dbg << " lock screen"; return dbg; } +#endif // !QT_NO_DEBUG_STREAM // Return the cursor to be shared by all screens (virtual desktop). static inline QSharedPointer sharedCursor() diff --git a/src/plugins/platforms/windows/qwindowstabletsupport.cpp b/src/plugins/platforms/windows/qwindowstabletsupport.cpp index 3951401273..b27811df9e 100644 --- a/src/plugins/platforms/windows/qwindowstabletsupport.cpp +++ b/src/plugins/platforms/windows/qwindowstabletsupport.cpp @@ -302,8 +302,11 @@ static inline QTabletEvent::PointerType pointerType(unsigned currentCursor) return QTabletEvent::UnknownPointer; } +#ifndef QT_NO_DEBUG_STREAM QDebug operator<<(QDebug d, const QWindowsTabletDeviceData &t) { + QDebugStateSaver saver(d); + d.nospace(); d << "TabletDevice id:" << t.uniqueId << " pressure: " << t.minPressure << ".." << t.maxPressure << " tan pressure: " << t.minTanPressure << ".." << t.maxTanPressure << " area:" << t.minX << t.minY <