From 64507c7165e42c2a5029353d8f97a0d841fa6b01 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Thu, 30 Jun 2016 21:47:14 +0200 Subject: [PATCH] Clean up qwindowdefs_win.h The file lives in Qt Gui, but declares a few methods from Qt Core and Widgets. All of those methods are actually mostly unused, not documented and pretty trivial. This patch removes the last few places the methods got used and removes the declarations. The implementations should get removed in a future release. Change-Id: I2b609c29f403d2ed4824ff4346008be08b3fd067 Reviewed-by: Marc Mutz --- src/corelib/kernel/qcoreapplication_win.cpp | 2 ++ src/corelib/kernel/qeventdispatcher_win.cpp | 7 +++---- src/gui/kernel/qwindowdefs_win.h | 9 --------- src/widgets/kernel/qapplication.cpp | 4 ++++ src/widgets/styles/qwindowsxpstyle.cpp | 7 +++++-- 5 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/corelib/kernel/qcoreapplication_win.cpp b/src/corelib/kernel/qcoreapplication_win.cpp index 67261645ac..67e509eeef 100644 --- a/src/corelib/kernel/qcoreapplication_win.cpp +++ b/src/corelib/kernel/qcoreapplication_win.cpp @@ -122,6 +122,7 @@ QString QCoreApplicationPrivate::appName() const #ifndef Q_OS_WINRT +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) Q_CORE_EXPORT HINSTANCE qWinAppInst() // get Windows app handle { return GetModuleHandle(0); @@ -145,6 +146,7 @@ Q_CORE_EXPORT int qWinAppCmdShow() // get main window sho : SW_SHOWDEFAULT; #endif } +#endif /***************************************************************************** qWinMain() - Initializes Windows. Called from WinMain() in qtmain_win.cpp diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp index e05de4f085..1a0efae2dc 100644 --- a/src/corelib/kernel/qeventdispatcher_win.cpp +++ b/src/corelib/kernel/qeventdispatcher_win.cpp @@ -55,7 +55,6 @@ QT_BEGIN_NAMESPACE -HINSTANCE qWinAppInst(); extern uint qGlobalPostedEventsCount(); #ifndef TIME_KILL_SYNCHRONOUS @@ -310,7 +309,7 @@ QWindowsMessageWindowClassContext::QWindowsMessageWindowClassContext() wc.lpfnWndProc = qt_internal_proc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; - wc.hInstance = qWinAppInst(); + wc.hInstance = GetModuleHandle(0); wc.hIcon = 0; wc.hCursor = 0; wc.hbrBackground = 0; @@ -327,7 +326,7 @@ QWindowsMessageWindowClassContext::QWindowsMessageWindowClassContext() QWindowsMessageWindowClassContext::~QWindowsMessageWindowClassContext() { if (className) { - UnregisterClass(className, qWinAppInst()); + UnregisterClass(className, GetModuleHandle(0)); delete [] className; } } @@ -345,7 +344,7 @@ static HWND qt_create_internal_window(const QEventDispatcherWin32 *eventDispatch 0, 0, 0, 0, // geometry HWND_MESSAGE, // parent 0, // menu handle - qWinAppInst(), // application + GetModuleHandle(0), // application 0); // windows creation data. if (!wnd) { diff --git a/src/gui/kernel/qwindowdefs_win.h b/src/gui/kernel/qwindowdefs_win.h index e904b7a645..b546fe305e 100644 --- a/src/gui/kernel/qwindowdefs_win.h +++ b/src/gui/kernel/qwindowdefs_win.h @@ -111,13 +111,4 @@ typedef long HRESULT; typedef struct tagMSG MSG; -QT_BEGIN_NAMESPACE - -Q_CORE_EXPORT HINSTANCE qWinAppInst(); -Q_CORE_EXPORT HINSTANCE qWinAppPrevInst(); -Q_CORE_EXPORT int qWinAppCmdShow(); -Q_WIDGETS_EXPORT HDC qt_win_display_dc(); - -QT_END_NAMESPACE - #endif // QWINDOWDEFS_WIN_H diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index b87dc17778..df467505d9 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -868,6 +868,7 @@ QApplication::~QApplication() #endif } +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) #if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) // #fixme: Remove. static HDC displayDC = 0; // display device context @@ -880,6 +881,7 @@ Q_WIDGETS_EXPORT HDC qt_win_display_dc() // get display D return displayDC; } #endif +#endif void qt_cleanup() { @@ -887,12 +889,14 @@ void qt_cleanup() QColormap::cleanup(); QApplicationPrivate::active_window = 0; //### this should not be necessary +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) #if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) if (displayDC) { ReleaseDC(0, displayDC); displayDC = 0; } #endif +#endif } /*! diff --git a/src/widgets/styles/qwindowsxpstyle.cpp b/src/widgets/styles/qwindowsxpstyle.cpp index 2fbc40dc11..c0ea725b7b 100644 --- a/src/widgets/styles/qwindowsxpstyle.cpp +++ b/src/widgets/styles/qwindowsxpstyle.cpp @@ -451,8 +451,11 @@ HBITMAP QWindowsXPStylePrivate::buffer(int w, int h) w = qMax(bufferW, w); h = qMax(bufferH, h); - if (!bufferDC) - bufferDC = CreateCompatibleDC(qt_win_display_dc()); + if (!bufferDC) { + HDC displayDC = GetDC(0); + bufferDC = CreateCompatibleDC(displayDC); + ReleaseDC(0, displayDC); + } // Define the header BITMAPINFO bmi;