From 960cab9994e58599f0ca81232f8e9d8ca2370f7c Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Tue, 8 Oct 2019 15:39:32 -0700 Subject: [PATCH 1/2] Qt 5.13 warnings & fixes --- .../src/AssignmentClientMonitor.cpp | 2 +- interface/src/Application.cpp | 12 +++-- interface/src/Application.h | 6 --- interface/src/main.cpp | 1 + .../src/display-plugins/CompositorHelper.cpp | 46 +++++++++++++++---- .../display-plugins/OpenGLDisplayPlugin.cpp | 2 +- .../display-plugins/hmd/HmdDisplayPlugin.cpp | 2 +- .../entities/src/EntityScriptingInterface.cpp | 4 +- libraries/fbx/src/GLTFSerializer.cpp | 6 +-- libraries/image/src/image/Image.cpp | 2 +- libraries/networking/src/HifiSockAddr.cpp | 7 +++ libraries/networking/src/HifiSockAddr.h | 7 +-- libraries/networking/src/LimitedNodeList.cpp | 4 ++ libraries/networking/src/udt/Socket.cpp | 8 ++++ libraries/render-utils/src/text/Font.cpp | 2 +- libraries/shared/src/MovingPercentile.cpp | 8 ++-- libraries/shared/src/SharedUtil.cpp | 11 +---- libraries/task/src/task/Config.h | 3 +- libraries/ui/src/InfoView.cpp | 4 +- libraries/ui/src/MainWindow.cpp | 10 ++-- 20 files changed, 91 insertions(+), 56 deletions(-) diff --git a/assignment-client/src/AssignmentClientMonitor.cpp b/assignment-client/src/AssignmentClientMonitor.cpp index 6601be849f..4c7f71a7aa 100644 --- a/assignment-client/src/AssignmentClientMonitor.cpp +++ b/assignment-client/src/AssignmentClientMonitor.cpp @@ -33,7 +33,7 @@ const QString ASSIGNMENT_CLIENT_MONITOR_TARGET_NAME = "assignment-client-monitor const int WAIT_FOR_CHILD_MSECS = 1000; #ifdef Q_OS_WIN -HANDLE PROCESS_GROUP = createProcessGroup(); +void* PROCESS_GROUP = createProcessGroup(); #endif AssignmentClientMonitor::AssignmentClientMonitor(const unsigned int numAssignmentClientForks, diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 4766353eba..421741b0a2 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -252,6 +252,7 @@ #if defined(Q_OS_WIN) #include +#include // On Windows PC, NVidia Optimus laptop, we want to enable NVIDIA GPU // FIXME seems to be broken. @@ -532,6 +533,11 @@ bool isDomainURL(QUrl url) { } #ifdef Q_OS_WIN +static const UINT UWM_IDENTIFY_INSTANCES = + RegisterWindowMessage("UWM_IDENTIFY_INSTANCES_{8AB82783-B74A-4258-955B-8188C22AA0D6}_" + qgetenv("USERNAME")); +static const UINT UWM_SHOW_APPLICATION = + RegisterWindowMessage("UWM_SHOW_APPLICATION_{71123FD6-3DA8-4DC1-9C27-8A12A6250CBA}_" + qgetenv("USERNAME")); + class MyNativeEventFilter : public QAbstractNativeEventFilter { public: static MyNativeEventFilter& getInstance() { @@ -4957,7 +4963,7 @@ extern "C" { CCHAR NumberOfProcessors; }; - NTSYSCALLAPI NTSTATUS NTAPI NtQuerySystemInformation( + NTSYSCALLAPI LONG NTAPI NtQuerySystemInformation( _In_ SYSTEM_INFORMATION_CLASS SystemInformationClass, _Out_writes_bytes_opt_(SystemInformationLength) PVOID SystemInformation, _In_ ULONG SystemInformationLength, @@ -4966,12 +4972,12 @@ extern "C" { } template -NTSTATUS NtQuerySystemInformation(SYSTEM_INFORMATION_CLASS SystemInformationClass, T& t) { +LONG NtQuerySystemInformation(SYSTEM_INFORMATION_CLASS SystemInformationClass, T& t) { return NtQuerySystemInformation(SystemInformationClass, &t, (ULONG)sizeof(T), nullptr); } template -NTSTATUS NtQuerySystemInformation(SYSTEM_INFORMATION_CLASS SystemInformationClass, std::vector& t) { +LONG NtQuerySystemInformation(SYSTEM_INFORMATION_CLASS SystemInformationClass, std::vector& t) { return NtQuerySystemInformation(SystemInformationClass, t.data(), (ULONG)(sizeof(T) * t.size()), nullptr); } diff --git a/interface/src/Application.h b/interface/src/Application.h index af2348d1e9..e3334d12d6 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -91,12 +91,6 @@ namespace controller { class StateController; } -#ifdef Q_OS_WIN -static const UINT UWM_IDENTIFY_INSTANCES = - RegisterWindowMessage("UWM_IDENTIFY_INSTANCES_{8AB82783-B74A-4258-955B-8188C22AA0D6}_" + qgetenv("USERNAME")); -static const UINT UWM_SHOW_APPLICATION = - RegisterWindowMessage("UWM_SHOW_APPLICATION_{71123FD6-3DA8-4DC1-9C27-8A12A6250CBA}_" + qgetenv("USERNAME")); -#endif static const QString RUNNING_MARKER_FILENAME = "Interface.running"; static const QString SCRIPTS_SWITCH = "scripts"; diff --git a/interface/src/main.cpp b/interface/src/main.cpp index 9af1d07309..5ca4d18a45 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -36,6 +36,7 @@ #include "Profile.h" #ifdef Q_OS_WIN +#include extern "C" { typedef int(__stdcall * CHECKMINSPECPROC) (); } diff --git a/libraries/display-plugins/src/display-plugins/CompositorHelper.cpp b/libraries/display-plugins/src/display-plugins/CompositorHelper.cpp index d3cb602e5b..a1138b3018 100644 --- a/libraries/display-plugins/src/display-plugins/CompositorHelper.cpp +++ b/libraries/display-plugins/src/display-plugins/CompositorHelper.cpp @@ -15,10 +15,10 @@ #include #include -#include -#include +#include +#include #include -#include +#include #include #include @@ -177,9 +177,35 @@ QPointF CompositorHelper::getMouseEventPosition(QMouseEvent* event) { return event->localPos(); } +static bool isWindowActive() { + for (const auto& window : QGuiApplication::topLevelWindows()) { + if (window->isActive()) { + return true; + } + } + return false; +} + bool CompositorHelper::shouldCaptureMouse() const { + if (!_allowMouseCapture) { + return false; + } + + if (!isHMD()) { + return false; + } + + + if (!isWindowActive()) { + return false; + } + + if (ui::Menu::isSomeSubmenuShown()) { + return false; + } + // if we're in HMD mode, and some window of ours is active, but we're not currently showing a popup menu - return _allowMouseCapture && isHMD() && QApplication::activeWindow() && !ui::Menu::isSomeSubmenuShown(); + return true; } void CompositorHelper::setAllowMouseCapture(bool capture) { @@ -206,9 +232,9 @@ void CompositorHelper::handleLeaveEvent() { mainWidgetFrame.moveTopLeft(topLeftScreen); } QRect uncoveredRect = mainWidgetFrame; - foreach(QWidget* widget, QApplication::topLevelWidgets()) { - if (widget->isWindow() && widget->isVisible() && widget != mainWidget) { - QRect widgetFrame = widget->frameGeometry(); + for(QWindow* window : QGuiApplication::topLevelWindows()) { + if (window->isVisible() && window != mainWidget->windowHandle()) { + QRect widgetFrame = window->frameGeometry(); if (widgetFrame.intersects(uncoveredRect)) { QRect intersection = uncoveredRect & widgetFrame; if (intersection.top() > uncoveredRect.top()) { @@ -292,7 +318,7 @@ glm::vec2 CompositorHelper::getReticleMaximumPosition() const { if (isHMD()) { result = VIRTUAL_SCREEN_SIZE; } else { - QRect rec = QApplication::desktop()->screenGeometry(); + QRect rec = QGuiApplication::primaryScreen()->geometry(); result = glm::vec2(rec.right(), rec.bottom()); } return result; @@ -308,8 +334,8 @@ void CompositorHelper::sendFakeMouseEvent() { // in HMD mode we need to fake our mouse moves... QPoint globalPos(_reticlePositionInHMD.x, _reticlePositionInHMD.y); auto button = Qt::NoButton; - auto buttons = QApplication::mouseButtons(); - auto modifiers = QApplication::keyboardModifiers(); + auto buttons = QGuiApplication::mouseButtons(); + auto modifiers = QGuiApplication::keyboardModifiers(); QMouseEvent event(QEvent::MouseMove, globalPos, button, buttons, modifiers); _fakeMouseEvent = true; qApp->sendEvent(_renderingWidget, &event); diff --git a/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.cpp b/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.cpp index 55a15dadf0..f601b99779 100644 --- a/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.cpp +++ b/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.cpp @@ -373,7 +373,7 @@ void OpenGLDisplayPlugin::customizeContext() { auto usage = gpu::Texture::Usage::Builder().withColor().withAlpha(); cursorData.texture->setUsage(usage.build()); cursorData.texture->setStoredMipFormat(gpu::Element(gpu::VEC4, gpu::NUINT8, gpu::RGBA)); - cursorData.texture->assignStoredMip(0, image.byteCount(), image.constBits()); + cursorData.texture->assignStoredMip(0, image.sizeInBytes(), image.constBits()); cursorData.texture->setAutoGenerateMips(true); } } diff --git a/libraries/display-plugins/src/display-plugins/hmd/HmdDisplayPlugin.cpp b/libraries/display-plugins/src/display-plugins/hmd/HmdDisplayPlugin.cpp index 722ab341f7..0c8b661980 100644 --- a/libraries/display-plugins/src/display-plugins/hmd/HmdDisplayPlugin.cpp +++ b/libraries/display-plugins/src/display-plugins/hmd/HmdDisplayPlugin.cpp @@ -290,7 +290,7 @@ void HmdDisplayPlugin::internalPresent() { _previewTexture->setSource("HMD Preview Texture"); _previewTexture->setUsage(gpu::Texture::Usage::Builder().withColor().build()); _previewTexture->setStoredMipFormat(gpu::Element(gpu::VEC4, gpu::NUINT8, gpu::RGBA)); - _previewTexture->assignStoredMip(0, image.byteCount(), image.constBits()); + _previewTexture->assignStoredMip(0, image.sizeInBytes(), image.constBits()); _previewTexture->setAutoGenerateMips(true); auto viewport = getViewportForSourceSize(uvec2(_previewTexture->getDimensions())); diff --git a/libraries/entities/src/EntityScriptingInterface.cpp b/libraries/entities/src/EntityScriptingInterface.cpp index 7cfdc8a68d..3305d9ba00 100644 --- a/libraries/entities/src/EntityScriptingInterface.cpp +++ b/libraries/entities/src/EntityScriptingInterface.cpp @@ -666,7 +666,7 @@ QScriptValue EntityScriptingInterface::getMultipleEntityProperties(QScriptContex const int ARGUMENT_EXTENDED_DESIRED_PROPERTIES = 1; auto entityScriptingInterface = DependencyManager::get(); - const auto entityIDs = qScriptValueToValue>(context->argument(ARGUMENT_ENTITY_IDS)); + const auto entityIDs = qscriptvalue_cast>(context->argument(ARGUMENT_ENTITY_IDS)); return entityScriptingInterface->getMultipleEntityPropertiesInternal(engine, entityIDs, context->argument(ARGUMENT_EXTENDED_DESIRED_PROPERTIES)); } @@ -716,7 +716,7 @@ QScriptValue EntityScriptingInterface::getMultipleEntityPropertiesInternal(QScri psuedoPropertyFlags.set(EntityPsuedoPropertyFlag::FlagsActive); } - EntityPropertyFlags desiredProperties = qScriptValueToValue(extendedDesiredProperties); + EntityPropertyFlags desiredProperties = qscriptvalue_cast(extendedDesiredProperties); bool needsScriptSemantics = desiredProperties.getHasProperty(PROP_POSITION) || desiredProperties.getHasProperty(PROP_ROTATION) || desiredProperties.getHasProperty(PROP_LOCAL_POSITION) || diff --git a/libraries/fbx/src/GLTFSerializer.cpp b/libraries/fbx/src/GLTFSerializer.cpp index dca9e9fefa..da21c7995e 100755 --- a/libraries/fbx/src/GLTFSerializer.cpp +++ b/libraries/fbx/src/GLTFSerializer.cpp @@ -1859,7 +1859,7 @@ bool GLTFSerializer::readArray(const hifi::ByteArray& bin, int byteOffset, int c break; default: qWarning(modelformat) << "Unknown accessorType: " << accessorType; - blobstream.unsetDevice(); + blobstream.setDevice(nullptr); return false; } for (int i = 0; i < count; ++i) { @@ -1869,13 +1869,13 @@ bool GLTFSerializer::readArray(const hifi::ByteArray& bin, int byteOffset, int c blobstream >> value; outarray.push_back(value); } else { - blobstream.unsetDevice(); + blobstream.setDevice(nullptr); return false; } } } - blobstream.unsetDevice(); + blobstream.setDevice(nullptr); return true; } template diff --git a/libraries/image/src/image/Image.cpp b/libraries/image/src/image/Image.cpp index 2ef83e42d8..eb84521f5c 100644 --- a/libraries/image/src/image/Image.cpp +++ b/libraries/image/src/image/Image.cpp @@ -20,7 +20,7 @@ size_t Image::getByteCount() const { if (_format == Format_RGBAF) { return sizeof(FloatPixels::value_type) * _floatData.size(); } else { - return _packedData.byteCount(); + return _packedData.sizeInBytes(); } } diff --git a/libraries/networking/src/HifiSockAddr.cpp b/libraries/networking/src/HifiSockAddr.cpp index a1bfcdd275..086dd08489 100644 --- a/libraries/networking/src/HifiSockAddr.cpp +++ b/libraries/networking/src/HifiSockAddr.cpp @@ -17,6 +17,13 @@ #include "NetworkLogging.h" +#ifdef WIN32 +#include +#include +#else +#include +#endif + int hifiSockAddrMetaTypeId = qRegisterMetaType(); HifiSockAddr::HifiSockAddr() : diff --git a/libraries/networking/src/HifiSockAddr.h b/libraries/networking/src/HifiSockAddr.h index 3c753f0434..dcf7f9a6a9 100644 --- a/libraries/networking/src/HifiSockAddr.h +++ b/libraries/networking/src/HifiSockAddr.h @@ -15,12 +15,7 @@ #include #include -#ifdef WIN32 -#include -#include -#else -#include -#endif +struct sockaddr; #include diff --git a/libraries/networking/src/LimitedNodeList.cpp b/libraries/networking/src/LimitedNodeList.cpp index ecf2218e2f..c6b8bfb90b 100644 --- a/libraries/networking/src/LimitedNodeList.cpp +++ b/libraries/networking/src/LimitedNodeList.cpp @@ -38,6 +38,10 @@ #include "udt/Packet.h" #include "HMACAuth.h" +#if defined(Q_OS_WIN) +#include +#endif + static Setting::Handle LIMITED_NODELIST_LOCAL_PORT("LimitedNodeList.LocalPort", 0); using namespace std::chrono_literals; diff --git a/libraries/networking/src/udt/Socket.cpp b/libraries/networking/src/udt/Socket.cpp index 2d99f3649b..017855d628 100644 --- a/libraries/networking/src/udt/Socket.cpp +++ b/libraries/networking/src/udt/Socket.cpp @@ -31,6 +31,14 @@ using namespace udt; +#ifdef WIN32 +#include +#include +#else +#include +#endif + + Socket::Socket(QObject* parent, bool shouldChangeSocketOptions) : QObject(parent), _udpSocket(parent), diff --git a/libraries/render-utils/src/text/Font.cpp b/libraries/render-utils/src/text/Font.cpp index f9ca9d4cae..5cb5709252 100644 --- a/libraries/render-utils/src/text/Font.cpp +++ b/libraries/render-utils/src/text/Font.cpp @@ -258,7 +258,7 @@ void Font::read(QIODevice& in) { _texture = gpu::Texture::create2D(formatGPU, image.width(), image.height(), gpu::Texture::SINGLE_MIP, gpu::Sampler(gpu::Sampler::FILTER_MIN_POINT_MAG_LINEAR)); _texture->setStoredMipFormat(formatMip); - _texture->assignStoredMip(0, image.byteCount(), image.constBits()); + _texture->assignStoredMip(0, image.sizeInBytes(), image.constBits()); } void Font::setupGPU() { diff --git a/libraries/shared/src/MovingPercentile.cpp b/libraries/shared/src/MovingPercentile.cpp index 5bcdbb5e80..427f7f2078 100644 --- a/libraries/shared/src/MovingPercentile.cpp +++ b/libraries/shared/src/MovingPercentile.cpp @@ -46,13 +46,13 @@ void MovingPercentile::updatePercentile(qint64 sample) { // swap new sample with neighbors in _samplesSorted until it's in sorted order // try swapping up first, then down. element will only be swapped one direction. while (newSampleIndex < _samplesSorted.size() - 1 && sample > _samplesSorted[newSampleIndex + 1]) { - _samplesSorted.swap(newSampleIndex, newSampleIndex + 1); - _sampleIds.swap(newSampleIndex, newSampleIndex + 1); + std::swap(_samplesSorted[newSampleIndex], _samplesSorted[newSampleIndex + 1]); + std::swap(_sampleIds[newSampleIndex], _sampleIds[newSampleIndex + 1]); newSampleIndex++; } while (newSampleIndex > 0 && sample < _samplesSorted[newSampleIndex - 1]) { - _samplesSorted.swap(newSampleIndex, newSampleIndex - 1); - _sampleIds.swap(newSampleIndex, newSampleIndex - 1); + std::swap(_samplesSorted[newSampleIndex], _samplesSorted[newSampleIndex - 1]); + std::swap(_sampleIds[newSampleIndex], _sampleIds[newSampleIndex - 1]); newSampleIndex--; } diff --git a/libraries/shared/src/SharedUtil.cpp b/libraries/shared/src/SharedUtil.cpp index 39def1cab9..f14be72a71 100644 --- a/libraries/shared/src/SharedUtil.cpp +++ b/libraries/shared/src/SharedUtil.cpp @@ -22,6 +22,7 @@ #include #include +#include #include #ifdef Q_OS_WIN @@ -793,15 +794,7 @@ void printSystemInformation() { qCDebug(shared).noquote() << "\tKernel Type: " << QSysInfo::kernelType(); qCDebug(shared).noquote() << "\tKernel Version: " << QSysInfo::kernelVersion(); - auto macVersion = QSysInfo::macVersion(); - if (macVersion != QSysInfo::MV_None) { - qCDebug(shared) << "\tMac Version: " << macVersion; - } - - auto windowsVersion = QSysInfo::windowsVersion(); - if (windowsVersion != QSysInfo::WV_None) { - qCDebug(shared) << "\tWindows Version: " << windowsVersion; - } + qCDebug(shared) << "\tOS Version: " << QOperatingSystemVersion::current(); #ifdef Q_OS_WIN SYSTEM_INFO si; diff --git a/libraries/task/src/task/Config.h b/libraries/task/src/task/Config.h index 71d48c9a18..7e6be9b53e 100644 --- a/libraries/task/src/task/Config.h +++ b/libraries/task/src/task/Config.h @@ -18,6 +18,7 @@ #include #include #include +#include #include #include "SettingHandle.h" @@ -189,7 +190,7 @@ public: * @returns {object[]} */ Q_INVOKABLE QObjectList getSubConfigs() const { - auto list = findChildren(QRegExp(".*"), Qt::FindDirectChildrenOnly); + auto list = findChildren(QRegularExpression(".*"), Qt::FindDirectChildrenOnly); QObjectList returned; for (int i = 0; i < list.size(); i++) { returned.push_back(list[i]); diff --git a/libraries/ui/src/InfoView.cpp b/libraries/ui/src/InfoView.cpp index 650d43831c..478401c6f8 100644 --- a/libraries/ui/src/InfoView.cpp +++ b/libraries/ui/src/InfoView.cpp @@ -56,10 +56,10 @@ void InfoView::show(const QString& path, bool firstOrChangedOnly, QString urlQue const QString lastVersion = infoVersion.get(); const QString version = fetchVersion(url); // If we have version information stored - if (lastVersion != QString::null) { + if (!lastVersion.isNull()) { // Check to see the document version. If it's valid and matches // the stored version, we're done, so exit - if (version == QString::null || version == lastVersion) { + if (version.isNull() || version == lastVersion) { return; } } diff --git a/libraries/ui/src/MainWindow.cpp b/libraries/ui/src/MainWindow.cpp index 124e25675a..ffa9bacbaa 100644 --- a/libraries/ui/src/MainWindow.cpp +++ b/libraries/ui/src/MainWindow.cpp @@ -11,8 +11,8 @@ #include "MainWindow.h" -#include -#include +#include +#include #include #include #include @@ -22,8 +22,8 @@ #include #include #include -#include -#include +#include +#include #include "ui/Logging.h" #include "DockWidget.h" @@ -60,7 +60,7 @@ QWindow* MainWindow::findMainWindow() { void MainWindow::restoreGeometry() { // Did not use setGeometry() on purpose, // see http://doc.qt.io/qt-5/qsettings.html#restoring-the-state-of-a-gui-application - QRect windowGeometry = qApp->desktop()->availableGeometry(); + QRect windowGeometry = QGuiApplication::primaryScreen()->availableGeometry(); #if defined(Q_OS_MAC) windowGeometry.setSize((windowGeometry.size() * 0.5f)); #endif From 06871a707e776596d4471e1aede3cf8cf49624a7 Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Tue, 8 Oct 2019 16:11:00 -0700 Subject: [PATCH 2/2] Fix byteswap --- libraries/networking/src/LimitedNodeList.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libraries/networking/src/LimitedNodeList.cpp b/libraries/networking/src/LimitedNodeList.cpp index c6b8bfb90b..4b6adc8b01 100644 --- a/libraries/networking/src/LimitedNodeList.cpp +++ b/libraries/networking/src/LimitedNodeList.cpp @@ -40,6 +40,8 @@ #if defined(Q_OS_WIN) #include +#else +#include #endif static Setting::Handle LIMITED_NODELIST_LOCAL_PORT("LimitedNodeList.LocalPort", 0);