From a9e3bf31084f313fd47abd94d3fbfd7100886e66 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 24 Jan 2019 08:54:38 +0100 Subject: [PATCH] WIP: Windows QPA: Use nullptr Change-Id: I6ce01caa58de78e0eb61e243ee1e7b05cc1f5568 --- src/plugins/platforms/windows/main.cpp | 2 +- .../windows/qwindowsbackingstore.cpp | 4 +- .../platforms/windows/qwindowsclipboard.cpp | 18 ++--- .../platforms/windows/qwindowscontext.cpp | 58 +++++++-------- .../platforms/windows/qwindowscursor.cpp | 16 ++-- .../windows/qwindowsdialoghelpers.cpp | 74 +++++++++---------- .../platforms/windows/qwindowsdrag.cpp | 12 +-- .../platforms/windows/qwindowseglcontext.cpp | 30 ++++---- .../windows/qwindowsgdinativeinterface.cpp | 4 +- .../platforms/windows/qwindowsglcontext.cpp | 46 ++++++------ .../windows/qwindowsinputcontext.cpp | 10 +-- .../platforms/windows/qwindowsintegration.cpp | 4 +- .../windows/qwindowsinternalmimedata.cpp | 2 +- .../platforms/windows/qwindowskeymapper.cpp | 16 ++-- .../platforms/windows/qwindowsmenu.cpp | 2 +- .../platforms/windows/qwindowsmime.cpp | 18 ++--- .../windows/qwindowsmousehandler.cpp | 18 ++--- .../windows/qwindowsnativeinterface.cpp | 12 +-- src/plugins/platforms/windows/qwindowsole.cpp | 16 ++-- .../windows/qwindowsopengltester.cpp | 22 +++--- .../platforms/windows/qwindowsscreen.cpp | 14 ++-- .../platforms/windows/qwindowsservices.cpp | 12 +-- .../windows/qwindowssystemtrayicon.cpp | 7 +- .../platforms/windows/qwindowstheme.cpp | 24 +++--- .../windows/qwindowsvulkaninstance.cpp | 2 +- .../platforms/windows/qwindowswindow.cpp | 64 ++++++++-------- .../windows/uiautomation/qwindowsuiautils.cpp | 2 +- 27 files changed, 255 insertions(+), 254 deletions(-) diff --git a/src/plugins/platforms/windows/main.cpp b/src/plugins/platforms/windows/main.cpp index 8bde87c975..1929f800a4 100644 --- a/src/plugins/platforms/windows/main.cpp +++ b/src/plugins/platforms/windows/main.cpp @@ -112,7 +112,7 @@ QPlatformIntegration *QWindowsIntegrationPlugin::create(const QString& system, c { if (system.compare(system, QLatin1String("windows"), Qt::CaseInsensitive) == 0) return new QWindowsGdiIntegration(paramList); - return 0; + return nullptr; } QT_END_NAMESPACE diff --git a/src/plugins/platforms/windows/qwindowsbackingstore.cpp b/src/plugins/platforms/windows/qwindowsbackingstore.cpp index 03b44458ac..97dded9bdc 100644 --- a/src/plugins/platforms/windows/qwindowsbackingstore.cpp +++ b/src/plugins/platforms/windows/qwindowsbackingstore.cpp @@ -102,7 +102,7 @@ void QWindowsBackingStore::flush(QWindow *window, const QRegion ®ion, BLENDFUNCTION blend = {AC_SRC_OVER, 0, BYTE(qRound(255.0 * rw->opacity())), AC_SRC_ALPHA}; RECT dirty = {dirtyRect.x(), dirtyRect.y(), dirtyRect.x() + dirtyRect.width(), dirtyRect.y() + dirtyRect.height()}; - UPDATELAYEREDWINDOWINFO info = {sizeof(info), NULL, &ptDst, &size, m_image->hdc(), &ptSrc, 0, &blend, ULW_ALPHA, &dirty}; + UPDATELAYEREDWINDOWINFO info = {sizeof(info), nullptr, &ptDst, &size, m_image->hdc(), &ptSrc, 0, &blend, ULW_ALPHA, &dirty}; const BOOL result = UpdateLayeredWindowIndirect(rw->handle(), &info); if (!result) qErrnoWarning("UpdateLayeredWindowIndirect failed for ptDst=(%d, %d)," @@ -207,7 +207,7 @@ HDC QWindowsBackingStore::getDC() const { if (!m_image.isNull()) return m_image->hdc(); - return 0; + return nullptr; } QImage QWindowsBackingStore::toImage() const diff --git a/src/plugins/platforms/windows/qwindowsclipboard.cpp b/src/plugins/platforms/windows/qwindowsclipboard.cpp index 8b386da9f7..b87e43f3f7 100644 --- a/src/plugins/platforms/windows/qwindowsclipboard.cpp +++ b/src/plugins/platforms/windows/qwindowsclipboard.cpp @@ -115,13 +115,13 @@ static QDebug operator<<(QDebug d, const QMimeData *mimeData) IDataObject *QWindowsClipboardRetrievalMimeData::retrieveDataObject() const { - IDataObject * pDataObj = 0; + IDataObject * pDataObj = nullptr; if (OleGetClipboard(&pDataObj) == S_OK) { if (QWindowsContext::verbose > 1) qCDebug(lcQpaMime) << __FUNCTION__ << pDataObj; return pDataObj; } - return 0; + return nullptr; } void QWindowsClipboardRetrievalMimeData::releaseDataObject(IDataObject *dataObject) const @@ -148,7 +148,7 @@ static void cleanClipboardPostRoutine() cl->cleanup(); } -QWindowsClipboard *QWindowsClipboard::m_instance = 0; +QWindowsClipboard *QWindowsClipboard::m_instance = nullptr; QWindowsClipboard::QWindowsClipboard() { @@ -159,7 +159,7 @@ QWindowsClipboard::QWindowsClipboard() QWindowsClipboard::~QWindowsClipboard() { cleanup(); - QWindowsClipboard::m_instance = 0; + QWindowsClipboard::m_instance = nullptr; } void QWindowsClipboard::cleanup() @@ -174,7 +174,7 @@ void QWindowsClipboard::releaseIData() delete m_data->mimeData(); m_data->releaseQt(); m_data->Release(); - m_data = 0; + m_data = nullptr; } } @@ -207,10 +207,10 @@ void QWindowsClipboard::unregisterViewer() m_formatListenerRegistered = false; } else { ChangeClipboardChain(m_clipboardViewer, m_nextClipboardViewer); - m_nextClipboardViewer = 0; + m_nextClipboardViewer = nullptr; } DestroyWindow(m_clipboardViewer); - m_clipboardViewer = 0; + m_clipboardViewer = nullptr; } } @@ -300,7 +300,7 @@ QMimeData *QWindowsClipboard::mimeData(QClipboard::Mode mode) { qCDebug(lcQpaMime) << __FUNCTION__ << mode; if (mode != QClipboard::Clipboard) - return 0; + return nullptr; if (ownsClipboard()) return m_data->mimeData(); return &m_retrievalData; @@ -341,7 +341,7 @@ void QWindowsClipboard::setMimeData(QMimeData *mimeData, QClipboard::Mode mode) void QWindowsClipboard::clear() { - const HRESULT src = OleSetClipboard(0); + const HRESULT src = OleSetClipboard(nullptr); if (src != S_OK) qErrnoWarning("OleSetClipboard: Failed to clear the clipboard: 0x%lx", src); } diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp index 1f80ac5872..466e3397e8 100644 --- a/src/plugins/platforms/windows/qwindowscontext.cpp +++ b/src/plugins/platforms/windows/qwindowscontext.cpp @@ -112,7 +112,7 @@ static inline bool useRTL_Extensions() { // Since the IsValidLanguageGroup/IsValidLocale functions always return true on // Vista, check the Keyboard Layouts for enabling RTL. - if (const int nLayouts = GetKeyboardLayoutList(0, 0)) { + if (const int nLayouts = GetKeyboardLayoutList(0, nullptr)) { QScopedArrayPointer lpList(new HKL[nLayouts]); GetKeyboardLayoutList(nLayouts, lpList.data()); for (int i = 0; i < nLayouts; ++i) { @@ -237,7 +237,7 @@ void QWindowsShcoreDLL::init() QWindowsUser32DLL QWindowsContext::user32dll; QWindowsShcoreDLL QWindowsContext::shcoredll; -QWindowsContext *QWindowsContext::m_instance = 0; +QWindowsContext *QWindowsContext::m_instance = nullptr; /*! \class QWindowsContext @@ -257,7 +257,7 @@ struct QWindowsContextPrivate { unsigned m_systemInfo = 0; QSet m_registeredWindowClassNames; HandleBaseWindowHash m_windows; - HDC m_displayContext = 0; + HDC m_displayContext = nullptr; int m_defaultDPI = 96; QWindowsKeyMapper m_keyMapper; QWindowsMouseHandler m_mouseHandler; @@ -274,14 +274,14 @@ struct QWindowsContextPrivate { }; QWindowsContextPrivate::QWindowsContextPrivate() - : m_oleInitializeResult(OleInitialize(NULL)) + : m_oleInitializeResult(OleInitialize(nullptr)) { QWindowsContext::user32dll.init(); QWindowsContext::shcoredll.init(); if (m_pointerHandler.touchDevice() || m_mouseHandler.touchDevice()) m_systemInfo |= QWindowsContext::SI_SupportsTouch; - m_displayContext = GetDC(0); + m_displayContext = GetDC(nullptr); m_defaultDPI = GetDeviceCaps(m_displayContext, LOGPIXELSY); if (useRTL_Extensions()) { m_systemInfo |= QWindowsContext::SI_RTL_Extensions; @@ -316,7 +316,7 @@ QWindowsContext::~QWindowsContext() OleUninitialize(); d->m_screenManager.clearScreens(); // Order: Potentially calls back to the windows. - m_instance = 0; + m_instance = nullptr; } bool QWindowsContext::initTouch() @@ -400,7 +400,7 @@ int QWindowsContext::processDpiAwareness() { int result; if (QWindowsContext::shcoredll.getProcessDpiAwareness - && SUCCEEDED(QWindowsContext::shcoredll.getProcessDpiAwareness(NULL, &result))) { + && SUCCEEDED(QWindowsContext::shcoredll.getProcessDpiAwareness(nullptr, &result))) { return result; } return -1; @@ -549,7 +549,7 @@ QString QWindowsContext::registerWindowClass(QString cname, // add an instance-specific ID, the address of the window proc. static int classExists = -1; - const HINSTANCE appInstance = static_cast(GetModuleHandle(0)); + const HINSTANCE appInstance = static_cast(GetModuleHandle(nullptr)); if (classExists == -1) { WNDCLASS wcinfo; classExists = GetClassInfo(appInstance, reinterpret_cast(cname.utf16()), &wcinfo); @@ -569,7 +569,7 @@ QString QWindowsContext::registerWindowClass(QString cname, wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = appInstance; - wc.hCursor = 0; + wc.hCursor = nullptr; wc.hbrBackground = brush; if (icon) { wc.hIcon = static_cast(LoadImage(appInstance, L"IDI_ICON1", IMAGE_ICON, 0, 0, LR_DEFAULTSIZE)); @@ -578,15 +578,15 @@ QString QWindowsContext::registerWindowClass(QString cname, int sh = GetSystemMetrics(SM_CYSMICON); wc.hIconSm = static_cast(LoadImage(appInstance, L"IDI_ICON1", IMAGE_ICON, sw, sh, 0)); } else { - wc.hIcon = static_cast(LoadImage(0, IDI_APPLICATION, IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_SHARED)); - wc.hIconSm = 0; + wc.hIcon = static_cast(LoadImage(nullptr, IDI_APPLICATION, IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_SHARED)); + wc.hIconSm = nullptr; } } else { - wc.hIcon = 0; - wc.hIconSm = 0; + wc.hIcon = nullptr; + wc.hIconSm = nullptr; } - wc.lpszMenuName = 0; + wc.lpszMenuName = nullptr; wc.lpszClassName = reinterpret_cast(cname.utf16()); ATOM atom = RegisterClassEx(&wc); if (!atom) @@ -602,7 +602,7 @@ QString QWindowsContext::registerWindowClass(QString cname, void QWindowsContext::unregisterWindowClasses() { - const HINSTANCE appInstance = static_cast(GetModuleHandle(0)); + const HINSTANCE appInstance = static_cast(GetModuleHandle(nullptr)); for (const QString &name : qAsConst(d->m_registeredWindowClassNames)) { if (!UnregisterClass(reinterpret_cast(name.utf16()), appInstance) && QWindowsContext::verbose) @@ -623,7 +623,7 @@ QString QWindowsContext::windowsErrorMessage(unsigned long errorCode) const DWORD len = FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, errorCode, 0, reinterpret_cast(&lpMsgBuf), 0, NULL); + nullptr, errorCode, 0, reinterpret_cast(&lpMsgBuf), 0, nullptr); if (len) { rc = QString::fromUtf16(lpMsgBuf, int(len)); LocalFree(lpMsgBuf); @@ -643,7 +643,7 @@ void QWindowsContext::removeWindow(HWND hwnd) const HandleBaseWindowHash::iterator it = d->m_windows.find(hwnd); if (it != d->m_windows.end()) { if (d->m_keyMapper.keyGrabber() == it.value()->window()) - d->m_keyMapper.setKeyGrabber(0); + d->m_keyMapper.setKeyGrabber(nullptr); d->m_windows.erase(it); } } @@ -683,7 +683,7 @@ QWindow *QWindowsContext::findWindow(HWND hwnd) const { if (const QWindowsWindow *bw = findPlatformWindow(hwnd)) return bw->window(); - return 0; + return nullptr; } QWindow *QWindowsContext::windowUnderMouse() const @@ -750,7 +750,7 @@ QWindowsWindow *QWindowsContext::findPlatformWindowAt(HWND parent, const QPoint &screenPointIn, unsigned cwex_flags) const { - QWindowsWindow *result = 0; + QWindowsWindow *result = nullptr; const POINT screenPoint = { screenPointIn.x(), screenPointIn.y() }; while (findPlatformWindowHelper(screenPoint, cwex_flags, this, &parent, &result)) {} return result; @@ -822,7 +822,7 @@ HWND QWindowsContext::createDummyWindow(const QString &classNameIn, windowName, style, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, - HWND_MESSAGE, NULL, static_cast(GetModuleHandle(0)), NULL); + HWND_MESSAGE, nullptr, static_cast(GetModuleHandle(nullptr)), nullptr); } // Re-engineered from the inline function _com_error::ErrorMessage(). @@ -832,8 +832,8 @@ static inline QString errorMessageFromComError(const _com_error &comError) { TCHAR *message = nullptr; FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, - NULL, DWORD(comError.Error()), MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT), - message, 0, NULL); + nullptr, DWORD(comError.Error()), MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT), + message, 0, nullptr); if (message) { const QString result = QString::fromWCharArray(message).trimmed(); LocalFree(static_cast(message)); @@ -1321,7 +1321,7 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message, return false; platformWindow->setFlag(QWindowsWindow::WithinDpiChanged); const RECT *prcNewWindow = reinterpret_cast(lParam); - SetWindowPos(hwnd, NULL, prcNewWindow->left, prcNewWindow->top, + SetWindowPos(hwnd, nullptr, prcNewWindow->left, prcNewWindow->top, prcNewWindow->right - prcNewWindow->left, prcNewWindow->bottom - prcNewWindow->top, SWP_NOZORDER | SWP_NOACTIVATE); platformWindow->clearFlag(QWindowsWindow::WithinDpiChanged); @@ -1343,7 +1343,7 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message, qGuiAppPriv->commitData(); if (lParam & ENDSESSION_LOGOFF) - fflush(NULL); + fflush(nullptr); *result = sessionManager->wasCanceled() ? 0 : 1; return true; @@ -1361,7 +1361,7 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message, if (endsession && !qGuiAppPriv->aboutToQuitEmitted) { qGuiAppPriv->aboutToQuitEmitted = true; int index = QGuiApplication::staticMetaObject.indexOfSignal("aboutToQuit()"); - qApp->qt_metacall(QMetaObject::InvokeMetaMethod, index,0); + qApp->qt_metacall(QMetaObject::InvokeMetaMethod, index,nullptr); // since the process will be killed immediately quit() has no real effect QGuiApplication::quit(); } @@ -1382,10 +1382,10 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message, void QWindowsContext::handleFocusEvent(QtWindows::WindowsEventType et, QWindowsWindow *platformWindow) { - QWindow *nextActiveWindow = 0; + QWindow *nextActiveWindow = nullptr; if (et == QtWindows::FocusInEvent) { QWindow *topWindow = QWindowsWindow::topLevelOf(platformWindow->window()); - QWindow *modalWindow = 0; + QWindow *modalWindow = nullptr; if (QGuiApplicationPrivate::instance()->isWindowBlocked(topWindow, &modalWindow) && topWindow != modalWindow) { modalWindow->requestActivate(); return; @@ -1498,10 +1498,10 @@ static DWORD readDwordRegistrySetting(const wchar_t *regKey, const wchar_t *subK HKEY handle; if (RegOpenKeyEx(HKEY_CURRENT_USER, regKey, 0, KEY_READ, &handle) == ERROR_SUCCESS) { DWORD type; - if (RegQueryValueEx(handle, subKey, 0, &type, 0, 0) == ERROR_SUCCESS && type == REG_DWORD) { + if (RegQueryValueEx(handle, subKey, nullptr, &type, nullptr, nullptr) == ERROR_SUCCESS && type == REG_DWORD) { DWORD value; DWORD size = sizeof(result); - if (RegQueryValueEx(handle, subKey, 0, 0, reinterpret_cast(&value), &size) == ERROR_SUCCESS) + if (RegQueryValueEx(handle, subKey, nullptr, nullptr, reinterpret_cast(&value), &size) == ERROR_SUCCESS) result = value; } RegCloseKey(handle); diff --git a/src/plugins/platforms/windows/qwindowscursor.cpp b/src/plugins/platforms/windows/qwindowscursor.cpp index 4f669a5509..00d011ccec 100644 --- a/src/plugins/platforms/windows/qwindowscursor.cpp +++ b/src/plugins/platforms/windows/qwindowscursor.cpp @@ -102,7 +102,7 @@ QWindowsPixmapCursorCacheKey::QWindowsPixmapCursorCacheKey(const QCursor &c) HCURSOR QWindowsCursor::createPixmapCursor(QPixmap pixmap, const QPoint &hotSpot, qreal scaleFactor) { - HCURSOR cur = 0; + HCURSOR cur = nullptr; const qreal pixmapScaleFactor = scaleFactor / pixmap.devicePixelRatioF(); if (!qFuzzyCompare(pixmapScaleFactor, 1)) { pixmap = pixmap.scaled((pixmapScaleFactor * QSizeF(pixmap.size())).toSize(), @@ -161,7 +161,7 @@ static HCURSOR createBitmapCursor(const QImage &bbits, const QImage &mbits, ++x; } } - return CreateCursor(GetModuleHandle(0), hotSpot.x(), hotSpot.y(), width, height, + return CreateCursor(GetModuleHandle(nullptr), hotSpot.x(), hotSpot.y(), width, height, xBits.data(), xMask.data()); } @@ -456,7 +456,7 @@ QWindowsCursor::PixmapCursor QWindowsCursor::customCursor(Qt::CursorShape cursor const QSize cursorSize = systemCursorSize(screen); const QWindowsCustomPngCursor *sEnd = pngCursors + sizeof(pngCursors) / sizeof(pngCursors[0]); - const QWindowsCustomPngCursor *bestFit = 0; + const QWindowsCustomPngCursor *bestFit = nullptr; int sizeDelta = INT_MAX; for (const QWindowsCustomPngCursor *s = pngCursors; s < sEnd; ++s) { if (s->shape != cursorShape) @@ -532,7 +532,7 @@ HCURSOR QWindowsCursor::createCursorFromShape(Qt::CursorShape cursorShape, const } qWarning("%s: Invalid cursor shape %d", __FUNCTION__, cursorShape); - return 0; + return nullptr; } /*! @@ -741,10 +741,10 @@ QPixmap QWindowsCursor::dragDefaultCursor(Qt::DropAction action) const "...............XXXX....."}; if (m_ignoreDragCursor.isNull()) { - HCURSOR cursor = LoadCursor(NULL, IDC_NO); - ICONINFO iconInfo = {0, 0, 0, 0, 0}; + HCURSOR cursor = LoadCursor(nullptr, IDC_NO); + ICONINFO iconInfo = {0, 0, 0, nullptr, nullptr}; GetIconInfo(cursor, &iconInfo); - BITMAP bmColor = {0, 0, 0, 0, 0, 0, 0}; + BITMAP bmColor = {0, 0, 0, 0, 0, 0, nullptr}; if (iconInfo.hbmColor && GetObject(iconInfo.hbmColor, sizeof(BITMAP), &bmColor) @@ -780,7 +780,7 @@ HCURSOR QWindowsCursor::hCursor(const QCursor &c) const if (sit != m_standardCursorCache.constEnd()) return sit.value()->handle(); } - return HCURSOR(0); + return HCURSOR(nullptr); } /*! diff --git a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp index b629cc00a3..1e25d0b716 100644 --- a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp +++ b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp @@ -133,8 +133,8 @@ namespace QWindowsDialogs void eatMouseMove() { - MSG msg = {0, 0, 0, 0, 0, {0, 0} }; - while (PeekMessage(&msg, 0, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_REMOVE)) + MSG msg = {nullptr, 0, 0, 0, 0, {0, 0} }; + while (PeekMessage(&msg, nullptr, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_REMOVE)) ; if (msg.message == WM_MOUSEMOVE) PostMessage(msg.hwnd, msg.message, 0, msg.lParam); @@ -180,7 +180,7 @@ class QWindowsNativeDialogBase : public QObject public: virtual void setWindowTitle(const QString &title) = 0; bool executed() const { return m_executed; } - void exec(HWND owner = 0) { doExec(owner); m_executed = true; } + void exec(HWND owner = nullptr) { doExec(owner); m_executed = true; } signals: void accepted(); @@ -193,7 +193,7 @@ protected: QWindowsNativeDialogBase() : m_executed(false) {} private: - virtual void doExec(HWND owner = 0) = 0; + virtual void doExec(HWND owner = nullptr) = 0; bool m_executed; }; @@ -229,7 +229,7 @@ void QWindowsDialogHelperBase::cleanupThread() qCWarning(lcQpaDialogs) << __FUNCTION__ << "Thread terminated."; } delete m_thread; - m_thread = 0; + m_thread = nullptr; } } @@ -238,7 +238,7 @@ QWindowsNativeDialogBase *QWindowsDialogHelperBase::nativeDialog() co { if (m_nativeDialog.isNull()) { qWarning("%s invoked with no native dialog present.", __FUNCTION__); - return 0; + return nullptnullptr; } return m_nativeDialog.data(); } @@ -300,7 +300,7 @@ bool QWindowsDialogHelperBase::show(Qt::WindowFlags, if (parent) { m_ownerWindow = QWindowsWindow::handleOf(parent); } else { - m_ownerWindow = 0; + m_ownerWindow = nullptr; } qCDebug(lcQpaDialogs) << __FUNCTION__ << "modal=" << modal << " modal supported? " << supportsNonModalDialog(parent) @@ -347,7 +347,7 @@ void QWindowsDialogHelperBase::stopTimer() struct FindDialogContext { explicit FindDialogContext(const QString &titleIn) - : title(qStringToWCharArray(titleIn)), processId(GetCurrentProcessId()), hwnd(0) {} + : title(qStringToWCharArray(titleIn)), processId(GetCurrentProcessId()), hwnd(nullptr) {} const QScopedArrayPointer title; const DWORD processId; @@ -382,7 +382,7 @@ void QWindowsDialogHelperBase::hide() { if (m_nativeDialog) m_nativeDialog->close(); - m_ownerWindow = 0; + m_ownerWindow = nullptr; } template @@ -534,7 +534,7 @@ IFileDialogEvents *QWindowsNativeFileDialogEventHandler::create(QWindowsNativeFi QWindowsNativeFileDialogEventHandler *eventHandler = new QWindowsNativeFileDialogEventHandler(nativeFileDialog); if (FAILED(eventHandler->QueryInterface(IID_IFileDialogEvents, reinterpret_cast(&result)))) { qErrnoWarning("Unable to obtain IFileDialogEvents"); - return 0; + return nullptr; } eventHandler->Release(); return result; @@ -671,7 +671,7 @@ bool QWindowsShellItem::copyData(QIODevice *out) if (!canCopy() || !canStream()) return false; IStream *istream = nullptr; - HRESULT hr = m_item->BindToHandler(NULL, BHID_Stream, IID_PPV_ARGS(&istream)); + HRESULT hr = m_item->BindToHandler(nullptr, BHID_Stream, IID_PPV_ARGS(&istream)); if (FAILED(hr)) return false; enum : ULONG { bufSize = 102400 }; @@ -702,7 +702,7 @@ static IShellLibrary *sHLoadLibraryFromItem(IShellItem *libraryItem, DWORD mode) IShellLibrary *helper = nullptr; IShellLibrary *result = nullptr; - if (SUCCEEDED(CoCreateInstance(classId_ShellLibrary, NULL, CLSCTX_INPROC_SERVER, iId_IShellLibrary, reinterpret_cast(&helper)))) + if (SUCCEEDED(CoCreateInstance(classId_ShellLibrary, nullptr, CLSCTX_INPROC_SERVER, iId_IShellLibrary, reinterpret_cast(&helper)))) if (SUCCEEDED(helper->LoadLibraryFromItem(libraryItem, mode))) helper->QueryInterface(iId_IShellLibrary, reinterpret_cast(&result)); if (helper) @@ -800,7 +800,7 @@ public: inline void setDirectory(const QUrl &directory); inline void updateDirectory() { setDirectory(m_data.directory()); } inline QString directory() const; - void doExec(HWND owner = 0) override; + void doExec(HWND owner = nullptnullptr) override; virtual void setNameFilters(const QStringList &f); inline void selectNameFilter(const QString &filter); inline void updateSelectedNameFilter() { selectNameFilter(m_data.selectedNameFilter()); } @@ -869,7 +869,7 @@ QWindowsNativeFileDialogBase::~QWindowsNativeFileDialogBase() bool QWindowsNativeFileDialogBase::init(const CLSID &clsId, const IID &iid) { - HRESULT hr = CoCreateInstance(clsId, NULL, CLSCTX_INPROC_SERVER, + HRESULT hr = CoCreateInstance(clsId, nullptr, CLSCTX_INPROC_SERVER, iid, reinterpret_cast(&m_fileDialog)); if (FAILED(hr)) { qErrnoWarning("CoCreateInstance failed"); @@ -902,7 +902,7 @@ IShellItem *QWindowsNativeFileDialogBase::shellItem(const QUrl &url) const QString native = QDir::toNativeSeparators(url.toLocalFile()); const HRESULT hr = SHCreateItemFromParsingName(reinterpret_cast(native.utf16()), - NULL, IID_IShellItem, + nullptr, IID_IShellItem, reinterpret_cast(&result)); if (FAILED(hr)) { qErrnoWarning("%s: SHCreateItemFromParsingName(%s)) failed", __FUNCTION__, qPrintable(url.toString())); @@ -920,7 +920,7 @@ IShellItem *QWindowsNativeFileDialogBase::shellItem(const QUrl &url) return nullptr; } PIDLIST_ABSOLUTE idList; - HRESULT hr = SHGetKnownFolderIDList(uuid, 0, 0, &idList); + HRESULT hr = SHGetKnownFolderIDList(uuid, 0, nullptr, &idList); if (FAILED(hr)) { qErrnoWarning("%s: SHGetKnownFolderIDList(%s)) failed", __FUNCTION__, qPrintable(url.toString())); return nullptr; @@ -935,7 +935,7 @@ IShellItem *QWindowsNativeFileDialogBase::shellItem(const QUrl &url) } else { qWarning() << __FUNCTION__ << ": Unhandled scheme: " << url.scheme(); } - return 0; + return nullptr; } void QWindowsNativeFileDialogBase::setDirectory(const QUrl &directory) @@ -951,7 +951,7 @@ void QWindowsNativeFileDialogBase::setDirectory(const QUrl &directory) QString QWindowsNativeFileDialogBase::directory() const { QString result; - IShellItem *item = 0; + IShellItem *item = nullptr; if (m_fileDialog && SUCCEEDED(m_fileDialog->GetFolder(&item)) && item) { result = QWindowsShellItem(item).path(); item->Release(); @@ -1339,7 +1339,7 @@ void QWindowsNativeSaveFileDialog::setNameFilters(const QStringList &f) QList QWindowsNativeSaveFileDialog::dialogResult() const { QList result; - IShellItem *item = 0; + IShellItem *item = nullptr; if (SUCCEEDED(fileDialog()->GetResult(&item)) && item) result.append(QWindowsShellItem(item).url()); return result; @@ -1348,7 +1348,7 @@ QList QWindowsNativeSaveFileDialog::dialogResult() const QList QWindowsNativeSaveFileDialog::selectedFiles() const { QList result; - IShellItem *item = 0; + IShellItem *item = nullptr; const HRESULT hr = fileDialog()->GetCurrentSelection(&item); if (SUCCEEDED(hr) && item) { result.append(QWindowsShellItem(item).url()); @@ -1419,7 +1419,7 @@ static QString createTemporaryItemCopy(QWindowsShellItem &qItem) QList QWindowsNativeOpenFileDialog::dialogResult() const { QList result; - IShellItemArray *items = 0; + IShellItemArray *items = nullptr; if (SUCCEEDED(openFileDialog()->GetResults(&items)) && items) { for (IShellItem *item : QWindowsShellItem::itemsFromItemArray(items)) { QWindowsShellItem qItem(item); @@ -1441,7 +1441,7 @@ QList QWindowsNativeOpenFileDialog::dialogResult() const QList QWindowsNativeOpenFileDialog::selectedFiles() const { QList result; - IShellItemArray *items = 0; + IShellItemArray *items = nullptr; const HRESULT hr = openFileDialog()->GetSelectedItems(&items); if (SUCCEEDED(hr) && items) { for (IShellItem *item : QWindowsShellItem::itemsFromItemArray(items)) { @@ -1465,18 +1465,18 @@ QList QWindowsNativeOpenFileDialog::selectedFiles() const QWindowsNativeFileDialogBase *QWindowsNativeFileDialogBase::create(QFileDialogOptions::AcceptMode am, const QWindowsFileDialogSharedData &data) { - QWindowsNativeFileDialogBase *result = 0; + QWindowsNativeFileDialogBase *result = nullptr; if (am == QFileDialogOptions::AcceptOpen) { result = new QWindowsNativeOpenFileDialog(data); if (!result->init(CLSID_FileOpenDialog, IID_IFileOpenDialog)) { delete result; - return 0; + return nullptr; } } else { result = new QWindowsNativeSaveFileDialog(data); if (!result->init(CLSID_FileSaveDialog, IID_IFileSaveDialog)) { delete result; - return 0; + return nullptr; } } return result; @@ -1497,7 +1497,7 @@ class QWindowsFileDialogHelper : public QWindowsDialogHelperBaseacceptMode(), m_data); if (!result) - return 0; + return nullptr; QObject::connect(result, &QWindowsNativeDialogBase::accepted, this, &QPlatformDialogHelper::accept); QObject::connect(result, &QWindowsNativeDialogBase::rejected, this, &QPlatformDialogHelper::reject); QObject::connect(result, &QWindowsNativeFileDialogBase::directoryEntered, @@ -1638,7 +1638,7 @@ public: static QWindowsXpNativeFileDialog *create(const OptionsPtr &options, const QWindowsFileDialogSharedData &data); void setWindowTitle(const QString &t) override { m_title = t; } - void doExec(HWND owner = 0) override; + void doExec(HWND owner = nullptnullptr) override; int existingDirCallback(HWND hwnd, UINT uMsg, LPARAM lParam); @@ -1663,8 +1663,8 @@ private: static PtrGetSaveFileNameW m_getSaveFileNameW; }; -QWindowsXpNativeFileDialog::PtrGetOpenFileNameW QWindowsXpNativeFileDialog::m_getOpenFileNameW = 0; -QWindowsXpNativeFileDialog::PtrGetSaveFileNameW QWindowsXpNativeFileDialog::m_getSaveFileNameW = 0; +QWindowsXpNativeFileDialog::PtrGetOpenFileNameW QWindowsXpNativeFileDialog::m_getOpenFileNameW = nullptr; +QWindowsXpNativeFileDialog::PtrGetSaveFileNameW QWindowsXpNativeFileDialog::m_getSaveFileNameW = nullptr; QWindowsXpNativeFileDialog *QWindowsXpNativeFileDialog::create(const OptionsPtr &options, const QWindowsFileDialogSharedData &data) { @@ -1678,7 +1678,7 @@ QWindowsXpNativeFileDialog *QWindowsXpNativeFileDialog::create(const OptionsPtr } if (m_getOpenFileNameW && m_getSaveFileNameW) return new QWindowsXpNativeFileDialog(options, data); - return 0; + return nullptr; } QWindowsXpNativeFileDialog::QWindowsXpNativeFileDialog(const OptionsPtr &options, @@ -1755,8 +1755,8 @@ QList QWindowsXpNativeFileDialog::execExistingDir(HWND owner) wchar_t initPath[MAX_PATH]; initPath[0] = 0; bi.hwndOwner = owner; - bi.pidlRoot = NULL; - bi.lpszTitle = 0; + bi.pidlRoot = nullptr; + bi.lpszTitle = nullptr; bi.pszDisplayName = initPath; bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_STATUSTEXT | BIF_NEWDIALOGSTYLE; bi.lpfn = xpFileDialogGetExistingDirCallbackProc; @@ -1879,7 +1879,7 @@ class QWindowsXpFileDialogHelper : public QWindowsDialogHelperBaseoptions() & QWindowsIntegration::NoNativeDialogs) - return 0; + return nullptr; switch (type) { case QPlatformTheme::FileDialog: if (QWindowsIntegration::instance()->options() & QWindowsIntegration::XpNativeDialogs) @@ -2107,7 +2107,7 @@ QPlatformDialogHelper *createHelper(QPlatformTheme::DialogType type) default: break; } - return 0; + return nullptr; } } // namespace QWindowsDialogs diff --git a/src/plugins/platforms/windows/qwindowsdrag.cpp b/src/plugins/platforms/windows/qwindowsdrag.cpp index ee82b2f022..c754aadd01 100644 --- a/src/plugins/platforms/windows/qwindowsdrag.cpp +++ b/src/plugins/platforms/windows/qwindowsdrag.cpp @@ -80,7 +80,7 @@ QT_BEGIN_NAMESPACE class QWindowsDragCursorWindow : public QRasterWindow { public: - explicit QWindowsDragCursorWindow(QWindow *parent = 0); + explicit QWindowsDragCursorWindow(QWindow *parent = nullptnullptnullptr); void setPixmap(const QPixmap &p); @@ -264,7 +264,7 @@ QWindowsOleDropSource::QWindowsOleDropSource(QWindowsDrag *drag) , m_drag(drag) , m_windowUnderMouse(QWindowsContext::instance()->windowUnderMouse()) , m_currentButtons(Qt::NoButton) - , m_touchDragWindow(0) + , m_touchDragWindow(nullptr) { qCDebug(lcQpaMime) << __FUNCTION__ << m_mode; } @@ -572,7 +572,7 @@ QWindowsOleDropTarget::DragLeave() qCDebug(lcQpaMime) << __FUNCTION__ << ' ' << m_window; - QWindowSystemInterface::handleDrag(m_window, 0, QPoint(), Qt::IgnoreAction, + QWindowSystemInterface::handleDrag(m_window, nullptr, QPoint(), Qt::IgnoreAction, Qt::NoButton, Qt::NoModifier); if (!QDragManager::self()->source()) @@ -626,7 +626,7 @@ QWindowsOleDropTarget::Drop(LPDATAOBJECT pDataObj, DWORD grfKeyState, FORMATETC format; format.cfFormat = CLIPFORMAT(RegisterClipboardFormat(CFSTR_PERFORMEDDROPEFFECT)); format.tymed = TYMED_HGLOBAL; - format.ptd = 0; + format.ptd = nullptr; format.dwAspect = 1; format.lindex = -1; windowsDrag->dropDataObject()->SetData(&format, &medium, true); @@ -678,7 +678,7 @@ QMimeData *QWindowsDrag::dropData() */ IDropTargetHelper* QWindowsDrag::dropHelper() { if (!m_cachedDropTargetHelper) { - CoCreateInstance(CLSID_DragDropHelper, 0, CLSCTX_INPROC_SERVER, + CoCreateInstance(CLSID_DragDropHelper, nullptr, CLSCTX_INPROC_SERVER, IID_IDropTargetHelper, reinterpret_cast(&m_cachedDropTargetHelper)); } @@ -739,7 +739,7 @@ void QWindowsDrag::releaseDropDataObject() qCDebug(lcQpaMime) << __FUNCTION__ << m_dropDataObject; if (m_dropDataObject) { m_dropDataObject->Release(); - m_dropDataObject = 0; + m_dropDataObject = nullptr; } } diff --git a/src/plugins/platforms/windows/qwindowseglcontext.cpp b/src/plugins/platforms/windows/qwindowseglcontext.cpp index 52f3c56beb..70ba2784e9 100644 --- a/src/plugins/platforms/windows/qwindowseglcontext.cpp +++ b/src/plugins/platforms/windows/qwindowseglcontext.cpp @@ -103,7 +103,7 @@ static inline void *resolveFunc(HMODULE lib, const char *name) void *QWindowsLibEGL::resolve(const char *name) { - return m_lib ? resolveFunc(m_lib, name) : 0; + return m_lib ? resolveFunc(m_lib, name) : nullptr; } #endif // !QT_STATIC @@ -155,7 +155,7 @@ bool QWindowsLibEGL::init() if (!eglGetError || !eglGetDisplay || !eglInitialize || !eglGetProcAddress) return false; - eglGetPlatformDisplayEXT = 0; + eglGetPlatformDisplayEXT = nullptr; #ifdef EGL_ANGLE_platform_angle eglGetPlatformDisplayEXT = reinterpret_cast(eglGetProcAddress("eglGetPlatformDisplayEXT")); #endif @@ -166,7 +166,7 @@ bool QWindowsLibEGL::init() #if !defined(QT_STATIC) || defined(QT_OPENGL_DYNAMIC) void *QWindowsLibGLESv2::resolve(const char *name) { - return m_lib ? resolveFunc(m_lib, name) : 0; + return m_lib ? resolveFunc(m_lib, name) : nullptr; } #endif // !QT_STATIC @@ -213,7 +213,7 @@ bool QWindowsEGLStaticContext::initializeAngle(QWindowsOpenGLTester::Renderers p { EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_DEVICE_TYPE_WARP_ANGLE, EGL_NONE } }; - const EGLint *attributes = 0; + const EGLint *attributes = nullptr; if (preferredType & QWindowsOpenGLTester::AngleRendererD3d11) attributes = anglePlatformAttributes[0]; else if (preferredType & QWindowsOpenGLTester::AngleRendererD3d9) @@ -245,16 +245,16 @@ QWindowsEGLStaticContext *QWindowsEGLStaticContext::create(QWindowsOpenGLTester: const HDC dc = QWindowsContext::instance()->displayContext(); if (!dc){ qWarning("%s: No Display", __FUNCTION__); - return 0; + return nullptr; } if (!libEGL.init()) { qWarning("%s: Failed to load and resolve libEGL functions", __FUNCTION__); - return 0; + return nullptr; } if (!libGLESv2.init()) { qWarning("%s: Failed to load and resolve libGLESv2 functions", __FUNCTION__); - return 0; + return nullptr; } EGLDisplay display = EGL_NO_DISPLAY; @@ -271,7 +271,7 @@ QWindowsEGLStaticContext *QWindowsEGLStaticContext::create(QWindowsOpenGLTester: display = libEGL.eglGetDisplay(dc); if (!display) { qWarning("%s: Could not obtain EGL display", __FUNCTION__); - return 0; + return nullptr; } if (!major && !libEGL.eglInitialize(display, &major, &minor)) { @@ -279,7 +279,7 @@ QWindowsEGLStaticContext *QWindowsEGLStaticContext::create(QWindowsOpenGLTester: qWarning("%s: Could not initialize EGL display: error 0x%x", __FUNCTION__, err); if (err == 0x3001) qWarning("%s: When using ANGLE, check if d3dcompiler_4x.dll is available", __FUNCTION__); - return 0; + return nullptr; } qCDebug(lcQpaGl) << __FUNCTION__ << "Created EGL display" << display << 'v' <(nativeWindow), 0); + static_cast(nativeWindow), nullptr); if (surface == EGL_NO_SURFACE) { *err = libEGL.eglGetError(); qWarning("%s: Could not create the EGL window surface: 0x%x", __FUNCTION__, *err); @@ -390,7 +390,7 @@ QWindowsEGLContext::QWindowsEGLContext(QWindowsEGLStaticContext *staticContext, m_eglConfig = chooseConfig(format); m_format = m_staticContext->formatFromConfig(m_eglDisplay, m_eglConfig, format); - m_shareContext = share ? static_cast(share)->m_eglContext : 0; + m_shareContext = share ? static_cast(share)->m_eglContext : nullptr; QVector contextAttrs; contextAttrs.append(EGL_CONTEXT_CLIENT_VERSION); @@ -400,8 +400,8 @@ QWindowsEGLContext::QWindowsEGLContext(QWindowsEGLStaticContext *staticContext, QWindowsEGLStaticContext::libEGL.eglBindAPI(m_api); m_eglContext = QWindowsEGLStaticContext::libEGL.eglCreateContext(m_eglDisplay, m_eglConfig, m_shareContext, contextAttrs.constData()); if (m_eglContext == EGL_NO_CONTEXT && m_shareContext != EGL_NO_CONTEXT) { - m_shareContext = 0; - m_eglContext = QWindowsEGLStaticContext::libEGL.eglCreateContext(m_eglDisplay, m_eglConfig, 0, contextAttrs.constData()); + m_shareContext = nullptr; + m_eglContext = QWindowsEGLStaticContext::libEGL.eglCreateContext(m_eglDisplay, m_eglConfig, nullptr, contextAttrs.constData()); } if (m_eglContext == EGL_NO_CONTEXT) { @@ -862,11 +862,11 @@ EGLConfig QWindowsEGLContext::chooseConfig(const QSurfaceFormat &format) configureAttributes.append(EGL_NONE); EGLDisplay display = m_staticContext->display(); - EGLConfig cfg = 0; + EGLConfig cfg = nullptr; do { // Get the number of matching configurations for this set of properties. EGLint matching = 0; - if (!QWindowsEGLStaticContext::libEGL.eglChooseConfig(display, configureAttributes.constData(), 0, 0, &matching) || !matching) + if (!QWindowsEGLStaticContext::libEGL.eglChooseConfig(display, configureAttributes.constData(), nullptr, 0, &matching) || !matching) continue; // Fetch all of the matching configurations and find the diff --git a/src/plugins/platforms/windows/qwindowsgdinativeinterface.cpp b/src/plugins/platforms/windows/qwindowsgdinativeinterface.cpp index 4ba7108f45..08e11c5e39 100644 --- a/src/plugins/platforms/windows/qwindowsgdinativeinterface.cpp +++ b/src/plugins/platforms/windows/qwindowsgdinativeinterface.cpp @@ -48,13 +48,13 @@ void *QWindowsGdiNativeInterface::nativeResourceForBackingStore(const QByteArray { if (!bs || !bs->handle()) { qWarning("%s: '%s' requested for null backingstore or backingstore without handle.", __FUNCTION__, resource.constData()); - return 0; + return nullptr; } QWindowsBackingStore *wbs = static_cast(bs->handle()); if (resource == "getDC") return wbs->getDC(); qWarning("%s: Invalid key '%s' requested.", __FUNCTION__, resource.constData()); - return 0; + return nullptr; } QT_END_NAMESPACE diff --git a/src/plugins/platforms/windows/qwindowsglcontext.cpp b/src/plugins/platforms/windows/qwindowsglcontext.cpp index 851a6c961e..1f68b97107 100644 --- a/src/plugins/platforms/windows/qwindowsglcontext.cpp +++ b/src/plugins/platforms/windows/qwindowsglcontext.cpp @@ -322,7 +322,7 @@ static inline bool static void describeFormats(HDC hdc) { - const int pfiMax = DescribePixelFormat(hdc, 0, 0, NULL); + const int pfiMax = DescribePixelFormat(hdc, 0, 0, nullptr); for (int i = 0; i < pfiMax; i++) { PIXELFORMATDESCRIPTOR pfd; initPixelFormatDescriptor(&pfd); @@ -335,7 +335,7 @@ static void describeFormats(HDC hdc) namespace GDI { static QSurfaceFormat qSurfaceFormatFromPixelFormat(const PIXELFORMATDESCRIPTOR &pfd, - QWindowsOpenGLAdditionalFormat *additionalIn = 0) + QWindowsOpenGLAdditionalFormat *additionalIn = nullptr) { QSurfaceFormat format; format.setRenderableType(QSurfaceFormat::OpenGL); @@ -437,7 +437,7 @@ static int choosePixelFormat(HDC hdc, const QSurfaceFormat &format, return pixelFormat; } // 2) No matching format found, manual search loop. - const int pfiMax = DescribePixelFormat(hdc, 0, 0, NULL); + const int pfiMax = DescribePixelFormat(hdc, 0, 0, nullptr); int bestScore = -1; int bestPfi = -1; const bool stereoRequested = format.stereo(); @@ -479,7 +479,7 @@ static inline HGLRC createContext(HDC hdc, HGLRC shared) HGLRC result = QOpenGLStaticContext::opengl32.wglCreateContext(hdc); if (!result) { qErrnoWarning("%s: wglCreateContext failed.", __FUNCTION__); - return 0; + return nullptr; } if (shared && !QOpenGLStaticContext::opengl32.wglShareLists(shared, result)) qErrnoWarning("%s: wglShareLists() failed.", __FUNCTION__); @@ -590,7 +590,7 @@ static int choosePixelFormat(HDC hdc, uint numFormats = 0; while (true) { const bool valid = - staticContext.wglChoosePixelFormatARB(hdc, iAttributes, 0, 1, + staticContext.wglChoosePixelFormatARB(hdc, iAttributes, nullptr, 1, &pixelFormat, &numFormats) && numFormats >= 1; if (valid || (!sampleBuffersRequested && !srgbRequested)) @@ -646,7 +646,7 @@ static int choosePixelFormat(HDC hdc, static QSurfaceFormat qSurfaceFormatFromHDC(const QOpenGLStaticContext &staticContext, HDC hdc, int pixelFormat, - QWindowsOpenGLAdditionalFormat *additionalIn = 0) + QWindowsOpenGLAdditionalFormat *additionalIn = nullptr) { enum { attribSize = 42 }; @@ -720,12 +720,12 @@ static HGLRC createContext(const QOpenGLStaticContext &staticContext, HDC hdc, const QSurfaceFormat &format, const QWindowsOpenGLAdditionalFormat &, - HGLRC shared = 0) + HGLRC shared = nullptr) { enum { attribSize = 11 }; if (!staticContext.hasExtensions()) - return 0; + return nullptr; int attributes[attribSize]; int attribIndex = 0; std::fill(attributes, attributes + attribSize, int(0)); @@ -797,14 +797,14 @@ static inline HWND createDummyGLWindow() { return QWindowsContext::instance()-> createDummyWindow(QStringLiteral("QtOpenGLDummyWindow"), - L"OpenGLDummyWindow", 0, WS_OVERLAPPED | WS_CLIPCHILDREN | WS_CLIPSIBLINGS); + L"OpenGLDummyWindow", nullptr, WS_OVERLAPPED | WS_CLIPCHILDREN | WS_CLIPSIBLINGS); } // Create a dummy GL context (see QOpenGLTemporaryContext). static inline HGLRC createDummyGLContext(HDC dc) { if (!dc) - return 0; + return nullptr; PIXELFORMATDESCRIPTOR pixelFormDescriptor; initPixelFormatDescriptor(&pixelFormDescriptor); pixelFormDescriptor.dwFlags = PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW | PFD_GENERIC_FORMAT; @@ -813,16 +813,16 @@ static inline HGLRC createDummyGLContext(HDC dc) const int pixelFormat = ChoosePixelFormat(dc, &pixelFormDescriptor); if (!pixelFormat) { qErrnoWarning("%s: ChoosePixelFormat failed.", __FUNCTION__); - return 0; + return nullptr; } if (!QOpenGLStaticContext::opengl32.setPixelFormat(dc, pixelFormat, &pixelFormDescriptor)) { qErrnoWarning("%s: SetPixelFormat failed.", __FUNCTION__); - return 0; + return nullptr; } HGLRC rc = QOpenGLStaticContext::opengl32.wglCreateContext(dc); if (!rc) { qErrnoWarning("%s: wglCreateContext failed.", __FUNCTION__); - return 0; + return nullptr; } return rc; } @@ -1002,7 +1002,7 @@ QOpenGLStaticContext *QOpenGLStaticContext::create(bool softwareRendering) { if (!opengl32.init(softwareRendering)) { qWarning("Failed to load and resolve WGL/OpenGL functions"); - return 0; + return nullptr; } // We need a current context for wglGetProcAdress()/getGLString() to work. @@ -1033,12 +1033,12 @@ QWindowsGLContext::QWindowsGLContext(QOpenGLStaticContext *staticContext, QOpenGLContext *context) : m_staticContext(staticContext), m_context(context), - m_renderingContext(0), + m_renderingContext(nullptr), m_pixelFormat(0), m_extensionsUsed(false), m_swapInterval(-1), m_ownsContext(true), - m_getGraphicsResetStatus(0), + m_getGraphicsResetStatus(nullptr), m_lost(false) { if (!m_staticContext) // Something went very wrong. Stop here, isValid() will return false. @@ -1081,7 +1081,7 @@ QWindowsGLContext::QWindowsGLContext(QOpenGLStaticContext *staticContext, if (ok) m_ownsContext = false; else - m_renderingContext = 0; + m_renderingContext = nullptr; return; } @@ -1105,8 +1105,8 @@ QWindowsGLContext::QWindowsGLContext(QOpenGLStaticContext *staticContext, // Create a dummy one as we are not associated with a window yet. // Try to find a suitable pixel format using preferably ARB extensions // (default to GDI) and store that. - HWND dummyWindow = 0; - HDC hdc = 0; + HWND dummyWindow = nullptr; + HDC hdc = nullptr; bool tryExtensions = false; int obtainedSwapInterval = -1; do { @@ -1163,7 +1163,7 @@ QWindowsGLContext::QWindowsGLContext(QOpenGLStaticContext *staticContext, break; } // Create context with sharing, again preferably using ARB. - HGLRC sharingRenderingContext = 0; + HGLRC sharingRenderingContext = nullptr; if (const QPlatformOpenGLContext *sc = context->shareHandle()) sharingRenderingContext = static_cast(sc)->renderingContext(); @@ -1190,7 +1190,7 @@ QWindowsGLContext::QWindowsGLContext(QOpenGLStaticContext *staticContext, // Make the HGLRC retrievable via QOpenGLContext::nativeHandle(). // Do not provide the window since it is the dummy one and it is about to disappear. if (m_renderingContext) - context->setNativeHandle(QVariant::fromValue(QWGLNativeContext(m_renderingContext, 0))); + context->setNativeHandle(QVariant::fromValue(QWGLNativeContext(m_renderingContext, nullptr))); if (hdc) ReleaseDC(dummyWindow, hdc); @@ -1281,7 +1281,7 @@ static inline const QOpenGLContextData * if (e.hwnd == hwnd) return &e; } - return 0; + return nullptr; } void QWindowsGLContext::swapBuffers(QPlatformSurface *surface) @@ -1365,7 +1365,7 @@ void QWindowsGLContext::doneCurrent() if (QWindowsContext::verbose > 1) qCDebug(lcQpaGl) << __FUNCTION__ << this << m_windowContexts.size() << "contexts"; #endif // DEBUG_GL - QOpenGLStaticContext::opengl32.wglMakeCurrent(0, 0); + QOpenGLStaticContext::opengl32.wglMakeCurrent(nullptr, nullptr); releaseDCs(); } diff --git a/src/plugins/platforms/windows/qwindowsinputcontext.cpp b/src/plugins/platforms/windows/qwindowsinputcontext.cpp index d1e99c037b..8adcf56b11 100644 --- a/src/plugins/platforms/windows/qwindowsinputcontext.cpp +++ b/src/plugins/platforms/windows/qwindowsinputcontext.cpp @@ -311,10 +311,10 @@ void QWindowsInputContext::setWindowsImeEnabled(QWindowsWindow *platformWindow, return; if (enabled) { // Re-enable Windows IME by associating default context. - ImmAssociateContextEx(platformWindow->handle(), 0, IACE_DEFAULT); + ImmAssociateContextEx(platformWindow->handle(), nullptr, IACE_DEFAULT); } else { // Disable Windows IME by associating 0 context. - ImmAssociateContext(platformWindow->handle(), 0); + ImmAssociateContext(platformWindow->handle(), nullptr); } } @@ -539,7 +539,7 @@ bool QWindowsInputContext::composition(HWND hwnd, LPARAM lParamIn) // attribute sequence specifying the formatting of the converted part. int selStart, selLength; m_compositionContext.composition = getCompositionString(himc, GCS_COMPSTR); - m_compositionContext.position = ImmGetCompositionString(himc, GCS_CURSORPOS, 0, 0); + m_compositionContext.position = ImmGetCompositionString(himc, GCS_CURSORPOS, nullptr, 0); getCompositionStringConvertedRange(himc, &selStart, &selLength); if ((lParam & CS_INSERTCHAR) && (lParam & CS_NOMOVECARET)) { // make Korean work correctly. Hope this is correct for all IMEs @@ -620,11 +620,11 @@ void QWindowsInputContext::doneContext() { if (!m_compositionContext.hwnd) return; - m_compositionContext.hwnd = 0; + m_compositionContext.hwnd = nullptr; m_compositionContext.composition.clear(); m_compositionContext.position = 0; m_compositionContext.isComposing = false; - m_compositionContext.focusObject = 0; + m_compositionContext.focusObject = nullptr; } bool QWindowsInputContext::handleIME_Request(WPARAM wParam, diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp index cae1452885..2c90b0484e 100644 --- a/src/plugins/platforms/windows/qwindowsintegration.cpp +++ b/src/plugins/platforms/windows/qwindowsintegration.cpp @@ -461,7 +461,7 @@ QPlatformOpenGLContext *QWindowsIntegration::createPlatformOpenGLContext(QOpenGL if (result->isValid()) return result.take(); } - return 0; + return nullptr; } QOpenGLContext::OpenGLModuleType QWindowsIntegration::openGLModuleType() @@ -481,7 +481,7 @@ QWindowsStaticOpenGLContext *QWindowsIntegration::staticOpenGLContext() { QWindowsIntegration *integration = QWindowsIntegration::instance(); if (!integration) - return 0; + return nullptr; QWindowsIntegrationPrivate *d = integration->d.data(); QMutexLocker lock(&d->m_staticContextLock); if (d->m_staticOpenGLContext.isNull()) diff --git a/src/plugins/platforms/windows/qwindowsinternalmimedata.cpp b/src/plugins/platforms/windows/qwindowsinternalmimedata.cpp index 8f1d8f73d9..44b7523fa6 100644 --- a/src/plugins/platforms/windows/qwindowsinternalmimedata.cpp +++ b/src/plugins/platforms/windows/qwindowsinternalmimedata.cpp @@ -70,7 +70,7 @@ bool QWindowsInternalMimeData::hasFormat_sys(const QString &mime) const return false; const QWindowsMimeConverter &mc = QWindowsContext::instance()->mimeConverter(); - const bool has = mc.converterToMime(mime, pDataObj) != 0; + const bool has = mc.converterToMime(mime, pDataObj) != nullptr; releaseDataObject(pDataObj); qCDebug(lcQpaMime) << __FUNCTION__ << mime << has; return has; diff --git a/src/plugins/platforms/windows/qwindowskeymapper.cpp b/src/plugins/platforms/windows/qwindowskeymapper.cpp index 96abfdb9d7..b734ad848a 100644 --- a/src/plugins/platforms/windows/qwindowskeymapper.cpp +++ b/src/plugins/platforms/windows/qwindowskeymapper.cpp @@ -97,7 +97,7 @@ QT_BEGIN_NAMESPACE static void clearKeyRecorderOnApplicationInActive(Qt::ApplicationState state); QWindowsKeyMapper::QWindowsKeyMapper() - : m_useRTLExtensions(false), m_keyGrabber(0) + : m_useRTLExtensions(false), m_keyGrabber(nullptr) { memset(keyLayout, 0, sizeof(keyLayout)); QGuiApplication *app = static_cast(QGuiApplication::instance()); @@ -162,7 +162,7 @@ static void clearKeyRecorderOnApplicationInActive(Qt::ApplicationState state) KeyRecord *KeyRecorder::findKey(int code, bool remove) { - KeyRecord *result = 0; + KeyRecord *result = nullptr; for (int i = 0; i < nrecs; ++i) { if (records[i].code == code) { if (remove) { @@ -605,7 +605,7 @@ inline quint32 winceKeyBend(quint32 keyCode) } // Translate a VK into a Qt key code, or unicode character -static inline quint32 toKeyOrUnicode(quint32 vk, quint32 scancode, unsigned char *kbdBuffer, bool *isDeadkey = 0) +static inline quint32 toKeyOrUnicode(quint32 vk, quint32 scancode, unsigned char *kbdBuffer, bool *isDeadkey = nullptr) { Q_ASSERT(vk > 0 && vk < 256); quint32 code = 0; @@ -822,7 +822,7 @@ static void showSystemMenu(QWindow* w) TPM_LEFTALIGN | TPM_TOPALIGN | TPM_NONOTIFY | TPM_RETURNCMD, pos.x(), pos.y(), topLevelHwnd, - 0); + nullptr); if (ret) qWindowsWndProc(topLevelHwnd, WM_SYSCOMMAND, WPARAM(ret), 0); } @@ -1023,13 +1023,13 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, MSG msg, if (dirStatus == VK_LSHIFT && ((msg.wParam == VK_SHIFT && GetKeyState(VK_LCONTROL)) || (msg.wParam == VK_CONTROL && GetKeyState(VK_LSHIFT)))) { - sendExtendedPressRelease(receiver, Qt::Key_Direction_L, 0, scancode, vk_key, nModifiers, QString(), false); + sendExtendedPressRelease(receiver, Qt::Key_Direction_L, nullptr, scancode, vk_key, nModifiers, QString(), false); result = true; dirStatus = 0; } else if (dirStatus == VK_RSHIFT && ( (msg.wParam == VK_SHIFT && GetKeyState(VK_RCONTROL)) || (msg.wParam == VK_CONTROL && GetKeyState(VK_RSHIFT)))) { - sendExtendedPressRelease(receiver, Qt::Key_Direction_R, 0, scancode, vk_key, nModifiers, QString(), false); + sendExtendedPressRelease(receiver, Qt::Key_Direction_R, nullptr, scancode, vk_key, nModifiers, QString(), false); result = true; dirStatus = 0; } else { @@ -1140,7 +1140,7 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, MSG msg, // This will stop the auto-repeat of the key, should a modifier change, for example if (rec && rec->state != state) { key_recorder.findKey(int(msg.wParam), true); - rec = 0; + rec = nullptr; } // Find unicode character from Windows Message Queue @@ -1150,7 +1150,7 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, MSG msg, : msgType == WM_IME_KEYDOWN ? WM_IME_CHAR : WM_SYSCHAR); QChar uch; - if (PeekMessage(&wm_char, 0, charType, charType, PM_REMOVE)) { + if (PeekMessage(&wm_char, nullptr, charType, charType, PM_REMOVE)) { if (QWindowsContext::filterNativeEvent(&wm_char, lResult)) return true; if (receiver && QWindowsContext::filterNativeEvent(receiver, &wm_char, lResult)) diff --git a/src/plugins/platforms/windows/qwindowsmenu.cpp b/src/plugins/platforms/windows/qwindowsmenu.cpp index 71802b9017..5a92a7cf90 100644 --- a/src/plugins/platforms/windows/qwindowsmenu.cpp +++ b/src/plugins/platforms/windows/qwindowsmenu.cpp @@ -797,7 +797,7 @@ QWindowsMenuBar *QWindowsMenuBar::menuBarOf(const QWindow *notYetCreatedWindow) static inline void forceNcCalcSize(HWND hwnd) { // Force WM_NCCALCSIZE to adjust margin: Does not appear to work? - SetWindowPos(hwnd, 0, 0, 0, 0, 0, + SetWindowPos(hwnd, nullptr, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER); } diff --git a/src/plugins/platforms/windows/qwindowsmime.cpp b/src/plugins/platforms/windows/qwindowsmime.cpp index ff0dccb0d9..c8ccd7bc8c 100644 --- a/src/plugins/platforms/windows/qwindowsmime.cpp +++ b/src/plugins/platforms/windows/qwindowsmime.cpp @@ -312,7 +312,7 @@ static FORMATETC setCf(int cf) formatetc.cfFormat = CLIPFORMAT(cf); formatetc.dwAspect = DVASPECT_CONTENT; formatetc.lindex = -1; - formatetc.ptd = NULL; + formatetc.ptd = nullptr; formatetc.tymed = TYMED_HGLOBAL; return formatetc; } @@ -328,7 +328,7 @@ static bool setData(const QByteArray &data, STGMEDIUM *pmedium) GlobalUnlock(hData); pmedium->tymed = TYMED_HGLOBAL; pmedium->hGlobal = hData; - pmedium->pUnkForRelease = 0; + pmedium->pUnkForRelease = nullptr; return true; } @@ -352,7 +352,7 @@ static QByteArray getData(int cf, IDataObject *pDataObj, int lindex = -1) ULONG actualRead = 0; LARGE_INTEGER pos = {{0, 0}}; //Move to front (can fail depending on the data model implemented) - HRESULT hr = s.pstm->Seek(pos, STREAM_SEEK_SET, NULL); + HRESULT hr = s.pstm->Seek(pos, STREAM_SEEK_SET, nullptr); while(SUCCEEDED(hr)){ hr = s.pstm->Read(szBuffer, sizeof(szBuffer), &actualRead); if (SUCCEEDED(hr) && actualRead > 0) { @@ -1123,11 +1123,11 @@ bool QWindowsMimeImage::convertFromMime(const FORMATETC &formatetc, const QMimeD bool QWindowsMimeImage::hasOriginalDIBV5(IDataObject *pDataObj) const { bool isSynthesized = true; - IEnumFORMATETC *pEnum =NULL; + IEnumFORMATETC *pEnum =nullptr; HRESULT res = pDataObj->EnumFormatEtc(1, &pEnum); if (res == S_OK && pEnum) { FORMATETC fc; - while ((res = pEnum->Next(1, &fc, 0)) == S_OK) { + while ((res = pEnum->Next(1, &fc, nullptr)) == S_OK) { if (fc.ptd) CoTaskMemFree(fc.ptd); if (fc.cfFormat == CF_DIB) @@ -1398,7 +1398,7 @@ static bool isCustomMimeType(const QString &mimeType) return mimeType.startsWith(QLatin1String(x_qt_windows_mime), Qt::CaseInsensitive); } -static QString customMimeType(const QString &mimeType, int *lindex = 0) +static QString customMimeType(const QString &mimeType, int *lindex = nullptnullptr) { int len = sizeof(x_qt_windows_mime) - 1; int n = mimeType.lastIndexOf(QLatin1Char('\"')) - len; @@ -1510,7 +1510,7 @@ QWindowsMime * QWindowsMimeConverter::converterToMime(const QString &mimeType, I if (m_mimes.at(i)->canConvertToMime(mimeType, pDataObj)) return m_mimes.at(i); } - return 0; + return nullptr; } QStringList QWindowsMimeConverter::allMimesForFormats(IDataObject *pDataObj) const @@ -1523,7 +1523,7 @@ QStringList QWindowsMimeConverter::allMimesForFormats(IDataObject *pDataObj) con if (hr == NOERROR) { FORMATETC fmtetc; - while (S_OK == fmtenum->Next(1, &fmtetc, 0)) { + while (S_OK == fmtenum->Next(1, &fmtetc, nullptr)) { for (int i= m_mimes.size() - 1; i >= 0; --i) { QString format = m_mimes.at(i)->mimeForFormat(fmtetc); if (!format.isEmpty() && !formats.contains(format)) { @@ -1550,7 +1550,7 @@ QWindowsMime * QWindowsMimeConverter::converterFromMime(const FORMATETC &formate if (m_mimes.at(i)->canConvertFromMime(formatetc, mimeData)) return m_mimes.at(i); } - return 0; + return nullptr; } QVector QWindowsMimeConverter::allFormatsForMime(const QMimeData *mimeData) const diff --git a/src/plugins/platforms/windows/qwindowsmousehandler.cpp b/src/plugins/platforms/windows/qwindowsmousehandler.cpp index fcdd179a31..737fd1d2a9 100644 --- a/src/plugins/platforms/windows/qwindowsmousehandler.cpp +++ b/src/plugins/platforms/windows/qwindowsmousehandler.cpp @@ -75,11 +75,11 @@ static inline void compressMouseMove(MSG *msg) // key release events (kls 2003-05-13): MSG keyMsg; bool done = false; - while (PeekMessage(&keyMsg, 0, WM_KEYFIRST, WM_KEYLAST, + while (PeekMessage(&keyMsg, nullptr, WM_KEYFIRST, WM_KEYLAST, PM_NOREMOVE)) { if (keyMsg.time < mouseMsg.time) { if ((keyMsg.lParam & 0xC0000000) == 0x40000000) { - PeekMessage(&keyMsg, 0, keyMsg.message, + PeekMessage(&keyMsg, nullptr, keyMsg.message, keyMsg.message, PM_REMOVE); } else { done = true; @@ -121,7 +121,7 @@ static inline QTouchDevice *createTouchDevice() { const int digitizers = GetSystemMetrics(SM_DIGITIZER); if (!(digitizers & (NID_INTEGRATED_TOUCH | NID_EXTERNAL_TOUCH))) - return 0; + return nullptr; const int tabletPc = GetSystemMetrics(SM_TABLETPC); const int maxTouchPoints = GetSystemMetrics(SM_MAXIMUMTOUCHES); qCDebug(lcQpaEvents) << "Digitizers:" << hex << showbase << (digitizers & ~NID_READY) @@ -159,7 +159,7 @@ QTouchDevice *QWindowsMouseHandler::ensureTouchDevice() Qt::MouseButtons QWindowsMouseHandler::queryMouseButtons() { - Qt::MouseButtons result = 0; + Qt::MouseButtons result = nullptr; const bool mouseSwapped = GetSystemMetrics(SM_SWAPBUTTON); if (GetAsyncKeyState(VK_LBUTTON) < 0) result |= mouseSwapped ? Qt::RightButton: Qt::LeftButton; @@ -327,8 +327,8 @@ bool QWindowsMouseHandler::translateMouseEvent(QWindow *window, HWND hwnd, QWindow *leaveTarget = m_windowUnderMouse ? m_windowUnderMouse : m_trackedWindow; qCDebug(lcQpaEvents) << "Generating leave event for " << leaveTarget; QWindowSystemInterface::handleLeaveEvent(leaveTarget); - m_trackedWindow = 0; - m_windowUnderMouse = 0; + m_trackedWindow = nullptr; + m_windowUnderMouse = nullptr; } return true; } @@ -430,7 +430,7 @@ bool QWindowsMouseHandler::translateMouseEvent(QWindow *window, HWND hwnd, if (currentNotCapturing) { // Clear tracking if capturing and current window is not the capturing window // to avoid leave when mouse actually leaves the application. - m_trackedWindow = 0; + m_trackedWindow = nullptr; // We are not officially in any window, but we need to set some cursor to clear // whatever cursor the left window had, so apply the cursor of the capture window. platformWindow->applyCursor(); @@ -464,7 +464,7 @@ bool QWindowsMouseHandler::translateMouseEvent(QWindow *window, HWND hwnd, QWindowsKeyMapper::queryKeyboardModifiers(), source); } - m_previousCaptureWindow = hasCapture ? window : 0; + m_previousCaptureWindow = hasCapture ? window : nullptr; // QTBUG-48117, force synchronous handling for the extra buttons so that WM_APPCOMMAND // is sent for unhandled WM_XBUTTONDOWN. return (msg.message != WM_XBUTTONUP && msg.message != WM_XBUTTONDOWN && msg.message != WM_XBUTTONDBLCLK) @@ -595,7 +595,7 @@ bool QWindowsMouseHandler::translateTouchEvent(QWindow *window, HWND, QTouchPointList touchPoints; touchPoints.reserve(winTouchPointCount); - Qt::TouchPointStates allStates = 0; + Qt::TouchPointStates allStates = nullptr; GetTouchInputInfo(reinterpret_cast(msg.lParam), UINT(msg.wParam), winTouchInputs.data(), sizeof(TOUCHINPUT)); diff --git a/src/plugins/platforms/windows/qwindowsnativeinterface.cpp b/src/plugins/platforms/windows/qwindowsnativeinterface.cpp index a1ff6f1141..7b314878f5 100644 --- a/src/plugins/platforms/windows/qwindowsnativeinterface.cpp +++ b/src/plugins/platforms/windows/qwindowsnativeinterface.cpp @@ -95,7 +95,7 @@ void *QWindowsNativeInterface::nativeResourceForWindow(const QByteArray &resourc { if (!window || !window->handle()) { qWarning("%s: '%s' requested for null window or window without handle.", __FUNCTION__, resource.constData()); - return 0; + return nullptr; } QWindowsWindow *bw = static_cast(window->handle()); int type = resourceType(resource); @@ -108,7 +108,7 @@ void *QWindowsNativeInterface::nativeResourceForWindow(const QByteArray &resourc return bw->getDC(); if (type == ReleaseDCType) { bw->releaseDC(); - return 0; + return nullptr; } break; case QWindow::VulkanSurface: @@ -121,7 +121,7 @@ void *QWindowsNativeInterface::nativeResourceForWindow(const QByteArray &resourc break; } qWarning("%s: Invalid key '%s' requested.", __FUNCTION__, resource.constData()); - return 0; + return nullptr; } #ifndef QT_NO_CURSOR @@ -179,7 +179,7 @@ void *QWindowsNativeInterface::nativeResourceForIntegration(const QByteArray &re } #endif - return 0; + return nullptr; } #ifndef QT_NO_OPENGL @@ -187,7 +187,7 @@ void *QWindowsNativeInterface::nativeResourceForContext(const QByteArray &resour { if (!context || !context->handle()) { qWarning("%s: '%s' requested for null context or context without handle.", __FUNCTION__, resource.constData()); - return 0; + return nullptr; } QWindowsOpenGLContext *glcontext = static_cast(context->handle()); @@ -204,7 +204,7 @@ void *QWindowsNativeInterface::nativeResourceForContext(const QByteArray &resour } qWarning("%s: Invalid key '%s' requested.", __FUNCTION__, resource.constData()); - return 0; + return nullptr; } #endif // !QT_NO_OPENGL diff --git a/src/plugins/platforms/windows/qwindowsole.cpp b/src/plugins/platforms/windows/qwindowsole.cpp index ad0442c8bd..e9c3f2cbf6 100644 --- a/src/plugins/platforms/windows/qwindowsole.cpp +++ b/src/plugins/platforms/windows/qwindowsole.cpp @@ -84,7 +84,7 @@ QWindowsOleDataObject::~QWindowsOleDataObject() = default; void QWindowsOleDataObject::releaseQt() { - data = 0; + data = nullptr; } QMimeData *QWindowsOleDataObject::mimeData() const @@ -142,7 +142,7 @@ QWindowsOleDataObject::QueryGetData(LPFORMATETC pformatetc) STDMETHODIMP QWindowsOleDataObject::GetCanonicalFormatEtc(LPFORMATETC, LPFORMATETC pformatetcOut) { - pformatetcOut->ptd = NULL; + pformatetcOut->ptd = nullptr; return ResultFromScode(E_NOTIMPL); } @@ -188,7 +188,7 @@ QWindowsOleDataObject::EnumFormatEtc(DWORD dwDirection, LPENUMFORMATETC FAR* ppe formatetc.cfFormat = CLIPFORMAT(CF_PERFORMEDDROPEFFECT); formatetc.dwAspect = DVASPECT_CONTENT; formatetc.lindex = -1; - formatetc.ptd = NULL; + formatetc.ptd = nullptr; formatetc.tymed = TYMED_HGLOBAL; fmtetcs.append(formatetc); } @@ -197,7 +197,7 @@ QWindowsOleDataObject::EnumFormatEtc(DWORD dwDirection, LPENUMFORMATETC FAR* ppe *ppenumFormatEtc = enumFmtEtc; if (enumFmtEtc->isNull()) { delete enumFmtEtc; - *ppenumFormatEtc = NULL; + *ppenumFormatEtc = nullptr; sc = E_OUTOFMEMORY; } @@ -295,7 +295,7 @@ QWindowsOleEnumFmtEtc::Next(ULONG celt, LPFORMATETC rgelt, ULONG FAR* pceltFetch ULONG i=0; ULONG nOffset; - if (rgelt == NULL) + if (rgelt == nullptr) return ResultFromScode(E_INVALIDARG); while (i < celt) { @@ -311,7 +311,7 @@ QWindowsOleEnumFmtEtc::Next(ULONG celt, LPFORMATETC rgelt, ULONG FAR* pceltFetch m_nIndex += i; - if (pceltFetched != NULL) + if (pceltFetched != nullptr) *pceltFetched = i; if (i != celt) @@ -354,7 +354,7 @@ QWindowsOleEnumFmtEtc::Reset() STDMETHODIMP QWindowsOleEnumFmtEtc::Clone(LPENUMFORMATETC FAR* newEnum) { - if (newEnum == NULL) + if (newEnum == nullptr) return ResultFromScode(E_INVALIDARG); QWindowsOleEnumFmtEtc *result = new QWindowsOleEnumFmtEtc(m_lpfmtetcs); @@ -371,7 +371,7 @@ QWindowsOleEnumFmtEtc::Clone(LPENUMFORMATETC FAR* newEnum) bool QWindowsOleEnumFmtEtc::copyFormatEtc(LPFORMATETC dest, const FORMATETC *src) const { - if (dest == NULL || src == NULL) + if (dest == nullptr || src == nullptr) return false; *dest = *src; diff --git a/src/plugins/platforms/windows/qwindowsopengltester.cpp b/src/plugins/platforms/windows/qwindowsopengltester.cpp index 3efccf0f32..2046135725 100644 --- a/src/plugins/platforms/windows/qwindowsopengltester.cpp +++ b/src/plugins/platforms/windows/qwindowsopengltester.cpp @@ -330,10 +330,10 @@ bool QWindowsOpenGLTester::testDesktopGL() typedef BOOL (WINAPI *MakeCurrentType)(HDC, HGLRC); typedef PROC (WINAPI *WglGetProcAddressType)(LPCSTR); - HMODULE lib = 0; - HWND wnd = 0; - HDC dc = 0; - HGLRC context = 0; + HMODULE lib = nullptr; + HWND wnd = nullptr; + HDC dc = nullptr; + HGLRC context = nullptr; LPCTSTR className = L"qtopengltest"; CreateContextType CreateContext = nullptr; @@ -367,18 +367,18 @@ bool QWindowsOpenGLTester::testDesktopGL() WNDCLASS wclass; wclass.cbClsExtra = 0; wclass.cbWndExtra = 0; - wclass.hInstance = static_cast(GetModuleHandle(0)); - wclass.hIcon = 0; - wclass.hCursor = 0; + wclass.hInstance = static_cast(GetModuleHandle(nullptr)); + wclass.hIcon = nullptr; + wclass.hCursor = nullptr; wclass.hbrBackground = HBRUSH(COLOR_BACKGROUND); - wclass.lpszMenuName = 0; + wclass.lpszMenuName = nullptr; wclass.lpfnWndProc = DefWindowProc; wclass.lpszClassName = className; wclass.style = CS_OWNDC; if (!RegisterClass(&wclass)) goto cleanup; wnd = CreateWindow(className, L"qtopenglproxytest", WS_OVERLAPPED, - 0, 0, 640, 480, 0, 0, wclass.hInstance, 0); + 0, 0, 640, 480, nullptr, nullptr, wclass.hInstance, nullptr); if (!wnd) goto cleanup; dc = GetDC(wnd); @@ -447,14 +447,14 @@ bool QWindowsOpenGLTester::testDesktopGL() cleanup: if (MakeCurrent) - MakeCurrent(0, 0); + MakeCurrent(nullptr, nullptr); if (context) DeleteContext(context); if (dc && wnd) ReleaseDC(wnd, dc); if (wnd) { DestroyWindow(wnd); - UnregisterClass(className, GetModuleHandle(0)); + UnregisterClass(className, GetModuleHandle(nullptr)); } // No FreeLibrary. Some implementations, Mesa in particular, deadlock when trying to unload. diff --git a/src/plugins/platforms/windows/qwindowsscreen.cpp b/src/plugins/platforms/windows/qwindowsscreen.cpp index 2eaf386d42..a161dc46e9 100644 --- a/src/plugins/platforms/windows/qwindowsscreen.cpp +++ b/src/plugins/platforms/windows/qwindowsscreen.cpp @@ -89,7 +89,7 @@ static bool monitorData(HMONITOR hMonitor, QWindowsScreenData *data) if (data->name == QLatin1String("WinDisc")) { data->flags |= QWindowsScreenData::LockScreen; } else { - if (const HDC hdc = CreateDC(info.szDevice, NULL, NULL, NULL)) { + if (const HDC hdc = CreateDC(info.szDevice, nullptr, nullptr, nullptr)) { const QDpi dpi = monitorDPI(hMonitor); data->dpi = dpi.first ? dpi : deviceDPI(hdc); data->depth = GetDeviceCaps(hdc, BITSPIXEL); @@ -137,7 +137,7 @@ BOOL QT_WIN_CALLBACK monitorEnumCallback(HMONITOR hMonitor, HDC, LPRECT, LPARAM static inline WindowsScreenDataList monitorData() { WindowsScreenDataList result; - EnumDisplayMonitors(0, 0, monitorEnumCallback, reinterpret_cast(&result)); + EnumDisplayMonitors(nullptr, nullptr, monitorEnumCallback, reinterpret_cast(&result)); return result; } @@ -209,7 +209,7 @@ QPixmap QWindowsScreen::grabWindow(WId window, int xIn, int yIn, int width, int height = windowSize.height() - yIn; // Create and setup bitmap - HDC display_dc = GetDC(0); + HDC display_dc = GetDC(nullptr); HDC bitmap_dc = CreateCompatibleDC(display_dc); HBITMAP bitmap = CreateCompatibleBitmap(display_dc, width, height); HGDIOBJ null_bitmap = SelectObject(bitmap_dc, bitmap); @@ -226,7 +226,7 @@ QPixmap QWindowsScreen::grabWindow(WId window, int xIn, int yIn, int width, int const QPixmap pixmap = qt_pixmapFromWinHBITMAP(bitmap); DeleteObject(bitmap); - ReleaseDC(0, display_dc); + ReleaseDC(nullptr, display_dc); return pixmap; } @@ -237,7 +237,7 @@ QPixmap QWindowsScreen::grabWindow(WId window, int xIn, int yIn, int width, int QWindow *QWindowsScreen::topLevelAt(const QPoint &point) const { - QWindow *result = 0; + QWindow *result = nullptr; if (QWindow *child = QWindowsScreen::windowAt(point, CWP_SKIPINVISIBLE)) result = QWindowsWindow::topLevelOf(child); qCDebug(lcQpaWindows) <<__FUNCTION__ << point << result; @@ -246,7 +246,7 @@ QWindow *QWindowsScreen::topLevelAt(const QPoint &point) const QWindow *QWindowsScreen::windowAt(const QPoint &screenPoint, unsigned flags) { - QWindow* result = 0; + QWindow* result = nullptr; if (QPlatformWindow *bw = QWindowsContext::instance()-> findPlatformWindowAt(GetDesktopWindow(), screenPoint, flags)) result = bw->window(); @@ -576,7 +576,7 @@ const QWindowsScreen *QWindowsScreenManager::screenAtDp(const QPoint &p) const const QWindowsScreen *QWindowsScreenManager::screenForHwnd(HWND hwnd) const { HMONITOR hMonitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONULL); - if (hMonitor == NULL) + if (hMonitor == nullptr) return nullptr; const auto it = std::find_if(m_screens.cbegin(), m_screens.cend(), diff --git a/src/plugins/platforms/windows/qwindowsservices.cpp b/src/plugins/platforms/windows/qwindowsservices.cpp index b6ed27464e..9504513a5e 100644 --- a/src/plugins/platforms/windows/qwindowsservices.cpp +++ b/src/plugins/platforms/windows/qwindowsservices.cpp @@ -58,9 +58,9 @@ static inline bool shellExecute(const QUrl &url) ? QDir::toNativeSeparators(url.toLocalFile()) : url.toString(QUrl::FullyEncoded); const quintptr result = - reinterpret_cast(ShellExecute(0, 0, + reinterpret_cast(ShellExecute(nullptr, nullptr, reinterpret_cast(nativeFilePath.utf16()), - 0, 0, SW_SHOWNORMAL)); + nullptr, nullptr, SW_SHOWNORMAL)); // ShellExecute returns a value greater than 32 if successful if (result <= 32) { qWarning("ShellExecute '%s' failed (error %s).", qPrintable(url.toString()), qPrintable(QString::number(result))); @@ -84,7 +84,7 @@ static inline QString mailCommand() QString keyName; if (!RegOpenKeyEx(HKEY_CURRENT_USER, mailUserKey, 0, KEY_READ, &handle)) { DWORD bufferSize = BufferSize; - if (!RegQueryValueEx(handle, L"Progid", 0, 0, reinterpret_cast(command), &bufferSize)) + if (!RegQueryValueEx(handle, L"Progid", nullptr, nullptr, reinterpret_cast(command), &bufferSize)) keyName = QString::fromWCharArray(command); RegCloseKey(handle); } @@ -95,7 +95,7 @@ static inline QString mailCommand() command[0] = 0; if (!RegOpenKeyExW(HKEY_CLASSES_ROOT, reinterpret_cast(keyName.utf16()), 0, KEY_READ, &handle)) { DWORD bufferSize = BufferSize; - RegQueryValueEx(handle, L"", 0, 0, reinterpret_cast(command), &bufferSize); + RegQueryValueEx(handle, L"", nullptr, nullptr, reinterpret_cast(command), &bufferSize); RegCloseKey(handle); } // QTBUG-57816: As of Windows 10, if there is no mail client installed, an entry like @@ -136,8 +136,8 @@ static inline bool launchMail(const QUrl &url) STARTUPINFO si; ZeroMemory(&si, sizeof(si)); si.cb = sizeof(si); - if (!CreateProcess(NULL, reinterpret_cast(const_cast(command.utf16())), - NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) { + if (!CreateProcess(nullptr, reinterpret_cast(const_cast(command.utf16())), + nullptr, nullptr, FALSE, 0, nullptr, nullptr, &si, &pi)) { qErrnoWarning("Unable to launch '%s'", qPrintable(command)); return false; } diff --git a/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp b/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp index 3c27f2914d..c8b3c06107 100644 --- a/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp +++ b/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp @@ -153,7 +153,7 @@ static inline HWND createTrayIconMessageWindow() { QWindowsContext *ctx = QWindowsContext::instance(); if (!ctx) - return 0; + return nullptr; // Register window class in the platform plugin. const QString className = ctx->registerWindowClass(QStringLiteral("QTrayIconMessageWindowClass"), @@ -163,7 +163,8 @@ static inline HWND createTrayIconMessageWindow() windowName, WS_OVERLAPPED, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, - NULL, NULL, (HINSTANCE)GetModuleHandle(0), NULL); + nullptr, nullptr, + static_cast(GetModuleHandle(nullptr)), nullptr); } /*! @@ -180,7 +181,7 @@ QWindowsSystemTrayIcon::QWindowsSystemTrayIcon() if (!MYWM_TASKBARCREATED) MYWM_TASKBARCREATED = RegisterWindowMessage(L"TaskbarCreated"); // Allow the WM_TASKBARCREATED message through the UIPI filter - ChangeWindowMessageFilterEx(m_hwnd, MYWM_TASKBARCREATED, MSGFLT_ALLOW, 0); + ChangeWindowMessageFilterEx(m_hwnd, MYWM_TASKBARCREATED, MSGFLT_ALLOW, nullptr); qCDebug(lcQpaTrayIcon) << __FUNCTION__ << this << "MYWM_TASKBARCREATED=" << MYWM_TASKBARCREATED; } diff --git a/src/plugins/platforms/windows/qwindowstheme.cpp b/src/plugins/platforms/windows/qwindowstheme.cpp index 4b70e915a8..04bf2edc62 100644 --- a/src/plugins/platforms/windows/qwindowstheme.cpp +++ b/src/plugins/platforms/windows/qwindowstheme.cpp @@ -159,7 +159,7 @@ public: void run() override { - m_init = CoInitializeEx(NULL, COINIT_MULTITHREADED); + m_init = CoInitializeEx(nullptr, COINIT_MULTITHREADED); QMutexLocker readyLocker(&m_readyMutex); while (!m_cancelled.load()) { @@ -381,7 +381,7 @@ static inline QPalette menuPalette(const QPalette &systemPalette) static inline QPalette *menuBarPalette(const QPalette &menuPalette) { - QPalette *result = 0; + QPalette *result = nullptr; if (booleanSystemParametersInfo(SPI_GETFLATMENU, false)) { result = new QPalette(menuPalette); const QColor menubar(getSysColor(COLOR_MENUBAR)); @@ -393,13 +393,13 @@ static inline QPalette *menuBarPalette(const QPalette &menuPalette) } const char *QWindowsTheme::name = "windows"; -QWindowsTheme *QWindowsTheme::m_instance = 0; +QWindowsTheme *QWindowsTheme::m_instance = nullptr; QWindowsTheme::QWindowsTheme() { m_instance = this; - std::fill(m_fonts, m_fonts + NFonts, static_cast(0)); - std::fill(m_palettes, m_palettes + NPalettes, static_cast(0)); + std::fill(m_fonts, m_fonts + NFonts, static_cast(nullptr)); + std::fill(m_palettes, m_palettes + NPalettes, static_cast(nullptr)); refresh(); refreshIconPixmapSizes(); } @@ -408,7 +408,7 @@ QWindowsTheme::~QWindowsTheme() { clearPalettes(); clearFonts(); - m_instance = 0; + m_instance = nullptr; } static inline QStringList iconThemeSearchPaths() @@ -481,7 +481,7 @@ QVariant QWindowsTheme::themeHint(ThemeHint hint) const void QWindowsTheme::clearPalettes() { qDeleteAll(m_palettes, m_palettes + NPalettes); - std::fill(m_palettes, m_palettes + NPalettes, static_cast(0)); + std::fill(m_palettes, m_palettes + NPalettes, static_cast(nullptr)); } void QWindowsTheme::refreshPalettes() @@ -498,7 +498,7 @@ void QWindowsTheme::refreshPalettes() void QWindowsTheme::clearFonts() { qDeleteAll(m_fonts, m_fonts + NFonts); - std::fill(m_fonts, m_fonts + NFonts, static_cast(0)); + std::fill(m_fonts, m_fonts + NFonts, static_cast(nullptr)); } void QWindowsTheme::refreshFonts() @@ -606,7 +606,7 @@ QPixmap QWindowsTheme::standardPixmap(StandardPixmap sp, const QSizeF &pixmapSiz int resourceId = -1; SHSTOCKICONID stockId = SIID_INVALID; UINT stockFlags = 0; - LPCTSTR iconName = 0; + LPCTSTR iconName = nullptr; switch (sp) { case DriveCDIcon: stockId = SIID_DRIVECD; @@ -716,7 +716,7 @@ QPixmap QWindowsTheme::standardPixmap(StandardPixmap sp, const QSizeF &pixmapSiz } if (iconName) { - HICON iconHandle = LoadIcon(NULL, iconName); + HICON iconHandle = LoadIcon(nullptr, iconName); QPixmap pixmap = qt_pixmapFromWinHICON(iconHandle); DestroyIcon(iconHandle); if (!pixmap.isNull()) @@ -776,7 +776,7 @@ static QPixmap pixmapFromShellImageList(int iImageList, const SHFILEINFO &info) // For MinGW: static const IID iID_IImageList = {0x46eb5926, 0x582e, 0x4017, {0x9f, 0xdf, 0xe8, 0x99, 0x8d, 0xaa, 0x9, 0x50}}; - IImageList *imageList = 0; + IImageList *imageList = nullptr; HRESULT hr = SHGetImageList(iImageList, iID_IImageList, reinterpret_cast(&imageList)); if (hr != S_OK) return result; @@ -832,7 +832,7 @@ QPixmap QWindowsFileIconEngine::filePixmap(const QSize &size, QIcon::Mode, QIcon { /* We don't use the variable, but by storing it statically, we * ensure CoInitialize is only called once. */ - static HRESULT comInit = CoInitialize(NULL); + static HRESULT comInit = CoInitialize(nullptr); Q_UNUSED(comInit); static QCache > dirIconEntryCache(1000); diff --git a/src/plugins/platforms/windows/qwindowsvulkaninstance.cpp b/src/plugins/platforms/windows/qwindowsvulkaninstance.cpp index 7a01483abd..e460dc4b4f 100644 --- a/src/plugins/platforms/windows/qwindowsvulkaninstance.cpp +++ b/src/plugins/platforms/windows/qwindowsvulkaninstance.cpp @@ -81,7 +81,7 @@ bool QWindowsVulkanInstance::supportsPresent(VkPhysicalDevice physicalDevice, VkSurfaceKHR QWindowsVulkanInstance::createSurface(HWND win) { - VkSurfaceKHR surface = 0; + VkSurfaceKHR surface = nullptr; if (!m_createSurface) { m_createSurface = reinterpret_cast( diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 6201da7b72..e4cbf13360 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -347,7 +347,7 @@ static bool applyBlurBehindWindow(HWND hwnd) if (DwmIsCompositionEnabled(&compositionEnabled) != S_OK) return false; - DWM_BLURBEHIND blurBehind = {0, 0, 0, 0}; + DWM_BLURBEHIND blurBehind = {0, 0, nullptr, 0}; if (compositionEnabled) { blurBehind.dwFlags = DWM_BB_ENABLE | DWM_BB_BLURREGION; @@ -403,12 +403,12 @@ static void setWindowOpacity(HWND hwnd, Qt::WindowFlags flags, bool hasAlpha, bo if (hasAlpha && !accelerated && (flags & Qt::FramelessWindowHint)) { // Non-GL windows with alpha: Use blend function to update. BLENDFUNCTION blend = {AC_SRC_OVER, 0, alpha, AC_SRC_ALPHA}; - UpdateLayeredWindow(hwnd, NULL, NULL, NULL, NULL, NULL, 0, &blend, ULW_ALPHA); + UpdateLayeredWindow(hwnd, nullptr, nullptr, nullptr, nullptr, nullptr, 0, &blend, ULW_ALPHA); } else { SetLayeredWindowAttributes(hwnd, 0, alpha, LWA_ALPHA); } } else if (IsWindowVisible(hwnd)) { // Repaint when switching from layered. - InvalidateRect(hwnd, NULL, TRUE); + InvalidateRect(hwnd, nullptr, TRUE); } } @@ -482,7 +482,7 @@ struct WindowCreationData typedef QWindowsWindowData WindowData; enum Flags { ForceChild = 0x1, ForceTopLevel = 0x2 }; - WindowCreationData() : parentHandle(0), type(Qt::Widget), style(0), exStyle(0), + WindowCreationData() : parentHandle(nullptr), type(Qt::Widget), style(0), exStyle(0), topLevel(false), popup(false), dialog(false), tool(false), embedded(false), hasAlpha(false) {} @@ -774,7 +774,7 @@ QWindowsWindowData style, pos.x(), pos.y(), context->frameWidth, context->frameHeight, - parentHandle, NULL, appinst, NULL); + parentHandle, nullptr, appinst, nullptr); qCDebug(lcQpaWindows).nospace() << "CreateWindowEx: returns " << w << ' ' << result.hwnd << " obtained geometry: " << context->obtainedGeometry << ' ' << context->margins; @@ -908,7 +908,7 @@ bool QWindowsGeometryHint::handleCalculateSize(const QMargins &customMargins, co ncp->rgrc[0].top += customMargins.top(); ncp->rgrc[0].right -= customMargins.right(); ncp->rgrc[0].bottom -= customMargins.bottom(); - result = 0; + result = nullptr; qCDebug(lcQpaWindows).nospace() << __FUNCTION__ << oldClientArea << '+' << customMargins << "-->" << ncp->rgrc[0] << ' ' << ncp->rgrc[1] << ' ' << ncp->rgrc[2] << ' ' << ncp->lppos->cx << ',' << ncp->lppos->cy; @@ -983,7 +983,7 @@ QWindowsBaseWindow *QWindowsBaseWindow::baseWindowOf(const QWindow *w) HWND QWindowsBaseWindow::handleOf(const QWindow *w) { const QWindowsBaseWindow *bw = QWindowsBaseWindow::baseWindowOf(w); - return bw ? bw->handle() : HWND(0); + return bw ? bw->handle() : HWND(nullptr); } bool QWindowsBaseWindow::isTopLevel_sys() const @@ -1009,7 +1009,7 @@ QMargins QWindowsBaseWindow::frameMargins_sys() const void QWindowsBaseWindow::hide_sys() // Normal hide, do not activate other windows. { - SetWindowPos(handle(),0 , 0, 0, 0, 0, + SetWindowPos(handle(),nullptr , 0, 0, 0, 0, SWP_HIDEWINDOW | SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE); } @@ -1078,7 +1078,7 @@ QWindowsForeignWindow::QWindowsForeignWindow(QWindow *window, HWND hwnd) void QWindowsForeignWindow::setParent(const QPlatformWindow *newParentWindow) { const bool wasTopLevel = isTopLevel_sys(); - const HWND newParent = newParentWindow ? reinterpret_cast(newParentWindow->winId()) : HWND(0); + const HWND newParent = newParentWindow ? reinterpret_cast(newParentWindow->winId()) : HWND(nullptr); const bool isTopLevel = !newParent; const DWORD oldStyle = style(); qCDebug(lcQpaWindows) << __FUNCTION__ << window() << "newParent=" @@ -1198,7 +1198,7 @@ QWindowsWindow::QWindowsWindow(QWindow *aWindow, const QWindowsWindowData &data) m_cursor(new CursorHandle), m_format(aWindow->requestedFormat()) #if QT_CONFIG(vulkan) - , m_vkSurface(0) + , m_vkSurface(nullptr) #endif { QWindowsContext::instance()->addWindow(m_data.hwnd, this); @@ -1298,19 +1298,19 @@ void QWindowsWindow::destroyWindow() QVulkanInstance *inst = window()->vulkanInstance(); if (inst) static_cast(inst->handle())->destroySurface(m_vkSurface); - m_vkSurface = 0; + m_vkSurface = nullptr; } #endif #ifndef QT_NO_OPENGL if (m_surface) { if (QWindowsStaticOpenGLContext *staticOpenGLContext = QWindowsIntegration::staticOpenGLContext()) staticOpenGLContext->destroyWindowSurface(m_surface); - m_surface = 0; + m_surface = nullptr; } #endif DestroyWindow(m_data.hwnd); context->removeWindow(m_data.hwnd); - m_data.hwnd = 0; + m_data.hwnd = nullptr; } } @@ -1359,7 +1359,7 @@ void QWindowsWindow::setDropSiteEnabled(bool dropEnabled) CoLockObjectExternal(m_dropTarget, false, true); m_dropTarget->Release(); RevokeDragDrop(m_data.hwnd); - m_dropTarget = 0; + m_dropTarget = nullptr; } #endif // QT_CONFIG(clipboard) && QT_CONFIG(draganddrop) } @@ -1480,7 +1480,7 @@ void QWindowsWindow::updateTransientParent() const return; // QTBUG-34503, // a popup stays on top, no parent, see also WindowCreationData::fromWindow(). // Update transient parent. const HWND oldTransientParent = GetWindow(m_data.hwnd, GW_OWNER); - HWND newTransientParent = 0; + HWND newTransientParent = nullptr; if (const QWindow *tp = window()->transientParent()) if (const QWindowsWindow *tw = QWindowsWindow::windowsWindowOf(tp)) if (!tw->testFlag(WithinDestroy)) // Prevent destruction by parent window (QTBUG-35499, QTBUG-36666) @@ -1573,7 +1573,7 @@ void QWindowsWindow::show_sys() const if (fakedMaximize) { setStyle(style() & ~WS_MAXIMIZEBOX); - SetWindowPos(m_data.hwnd, 0, 0, 0, 0, 0, + SetWindowPos(m_data.hwnd, nullptr, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_FRAMECHANGED); } @@ -1593,7 +1593,7 @@ void QWindowsWindow::setParent_sys(const QPlatformWindow *parent) { // Use GetAncestor instead of GetParent, as GetParent can return owner window for toplevels HWND oldParentHWND = parentHwnd(); - HWND newParentHWND = 0; + HWND newParentHWND = nullptr; if (parent) { const QWindowsWindow *parentW = static_cast(parent); newParentHWND = parentW->handle(); @@ -1603,13 +1603,13 @@ void QWindowsWindow::setParent_sys(const QPlatformWindow *parent) // NULL handle means desktop window, which also has its proper handle -> disambiguate HWND desktopHwnd = GetDesktopWindow(); if (oldParentHWND == desktopHwnd) - oldParentHWND = 0; + oldParentHWND = nullptr; if (newParentHWND == desktopHwnd) - newParentHWND = 0; + newParentHWND = nullptr; if (newParentHWND != oldParentHWND) { - const bool wasTopLevel = oldParentHWND == 0; - const bool isTopLevel = newParentHWND == 0; + const bool wasTopLevel = oldParentHWND == nullptr; + const bool isTopLevel = newParentHWND == nullptr; setFlag(WithinSetParent); SetParent(m_data.hwnd, newParentHWND); @@ -1836,7 +1836,7 @@ void QWindowsWindow::releaseDC() { if (m_hdc) { ReleaseDC(handle(), m_hdc); - m_hdc = 0; + m_hdc = nullptr; } } @@ -1870,7 +1870,7 @@ bool QWindowsWindow::handleWmPaint(HWND hwnd, UINT message, // GL software rendering (QTBUG-58178) and Windows 7/Aero off with some AMD cards // (QTBUG-60527) need InvalidateRect() to suppress artifacts while resizing. if (testFlag(OpenGLSurface) && (isSoftwareGl() || !dwmIsCompositionEnabled())) - InvalidateRect(hwnd, 0, false); + InvalidateRect(hwnd, nullptr, false); BeginPaint(hwnd, &ps); @@ -1878,7 +1878,7 @@ bool QWindowsWindow::handleWmPaint(HWND hwnd, UINT message, if (Q_UNLIKELY(!dwmIsCompositionEnabled()) && ((testFlag(OpenGLSurface) && testFlag(OpenGLDoubleBuffered)) || testFlag(VulkanSurface))) { - SelectClipRgn(ps.hdc, NULL); + SelectClipRgn(ps.hdc, nullptr); } // If the a window is obscured by another window (such as a child window) @@ -2089,7 +2089,7 @@ void QWindowsWindow::setWindowState_sys(Qt::WindowStates newState) // it before applying the normal geometry. if (windowVisibility_sys(m_data.hwnd) == QWindow::Maximized) ShowWindow(m_data.hwnd, SW_SHOWNOACTIVATE); - SetWindowPos(m_data.hwnd, 0, m_savedFrameGeometry.x(), m_savedFrameGeometry.y(), + SetWindowPos(m_data.hwnd, nullptr, m_savedFrameGeometry.x(), m_savedFrameGeometry.y(), m_savedFrameGeometry.width(), m_savedFrameGeometry.height(), swpf); if (!wasSync) clearFlag(SynchronousGeometryChangeEvent); @@ -2275,7 +2275,7 @@ static HRGN qRegionToWinRegion(const QRegion ®ion) void QWindowsWindow::setMask(const QRegion ®ion) { if (region.isEmpty()) { - SetWindowRgn(m_data.hwnd, 0, true); + SetWindowRgn(m_data.hwnd, nullptr, true); return; } const HRGN winRegion = qRegionToWinRegion(region); @@ -2308,7 +2308,7 @@ void QWindowsWindow::requestActivateWindow() if (QGuiApplication::applicationState() != Qt::ApplicationActive && QWindowsNativeInterface::windowActivationBehavior() == QWindowsWindowFunctions::AlwaysActivateWindow) { if (const HWND foregroundWindow = GetForegroundWindow()) { - foregroundThread = GetWindowThreadProcessId(foregroundWindow, NULL); + foregroundThread = GetWindowThreadProcessId(foregroundWindow, nullptr); if (foregroundThread && foregroundThread != currentThread) attached = AttachThreadInput(foregroundThread, currentThread, TRUE) == TRUE; if (attached) { @@ -2342,7 +2342,7 @@ bool QWindowsWindow::setKeyboardGrabEnabled(bool grab) context->setKeyGrabber(window()); } else { if (context->keyGrabber() == window()) - context->setKeyGrabber(0); + context->setKeyGrabber(nullptr); } return true; } @@ -2642,7 +2642,7 @@ static HICON createHIcon(const QIcon &icon, int xSize, int ySize) if (!pm.isNull()) return qt_pixmapToWinHICON(pm); } - return 0; + return nullptr; } void QWindowsWindow::setWindowIcon(const QIcon &icon) @@ -2700,7 +2700,7 @@ void QWindowsWindow::setCustomMargins(const QMargins &newCustomMargins) newFrame.moveTo(topLeft); qCDebug(lcQpaWindows) << __FUNCTION__ << oldCustomMargins << "->" << newCustomMargins << currentFrameGeometry << "->" << newFrame; - SetWindowPos(m_data.hwnd, 0, newFrame.x(), newFrame.y(), newFrame.width(), newFrame.height(), SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOACTIVATE); + SetWindowPos(m_data.hwnd, nullptr, newFrame.x(), newFrame.y(), newFrame.width(), newFrame.height(), SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOACTIVATE); } } @@ -2743,14 +2743,14 @@ void QWindowsWindow::invalidateSurface() QVulkanInstance *inst = window()->vulkanInstance(); if (inst) static_cast(inst->handle())->destroySurface(m_vkSurface); - m_vkSurface = 0; + m_vkSurface = nullptr; } #endif #ifndef QT_NO_OPENGL if (m_surface) { if (QWindowsStaticOpenGLContext *staticOpenGLContext = QWindowsIntegration::staticOpenGLContext()) staticOpenGLContext->destroyWindowSurface(m_surface); - m_surface = 0; + m_surface = nullptr; } #endif // QT_NO_OPENGL } diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiautils.cpp b/src/plugins/platforms/windows/uiautomation/qwindowsuiautils.cpp index fbb5c3b9ec..7980826b49 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiautils.cpp +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiautils.cpp @@ -90,7 +90,7 @@ HWND hwndForAccessible(const QAccessibleInterface *accessible) return QWindowsBaseWindow::handleOf(window); } } - return NULL; + return nullptr; } void clearVariant(VARIANT *variant) -- 2.17.1.windows.2