From 62489ed642aab24477638831649941f2f1497abb Mon Sep 17 00:00:00 2001 From: Vasily Date: Wed, 26 Dec 2018 22:32:21 +0100 Subject: [PATCH 01/21] Move global level strings into scope of main --- src/main.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 922bcc6..fdb600c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -10,21 +10,6 @@ #include #include "logging.h" -const char* logConfigFileName = "logging.conf"; - -const char* logConfigDefault = -"* GLOBAL:\n" -" FORMAT = \"[%level] %datetime{%Y-%M-%d %H:%m:%s}: %msg\"\n" -" FILENAME = \"AdvancedSettings.log\"\n" -" ENABLED = true\n" -" TO_FILE = true\n" -" TO_STANDARD_OUTPUT = true\n" -" MAX_LOG_FILE_SIZE = 2097152 ## 2MB\n" -"* TRACE:\n" -" ENABLED = false\n" -"* DEBUG:\n" -" ENABLED = false\n"; - INITIALIZE_EASYLOGGINGPP void myQtMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg) { @@ -141,6 +126,21 @@ enum ReturnErrorCode { int main(int argc, char *argv[]) { + const char* logConfigFileName = "logging.conf"; + + const char* logConfigDefault = + "* GLOBAL:\n" + " FORMAT = \"[%level] %datetime{%Y-%M-%d %H:%m:%s}: %msg\"\n" + " FILENAME = \"AdvancedSettings.log\"\n" + " ENABLED = true\n" + " TO_FILE = true\n" + " TO_STANDARD_OUTPUT = true\n" + " MAX_LOG_FILE_SIZE = 2097152 ## 2MB\n" + "* TRACE:\n" + " ENABLED = false\n" + "* DEBUG:\n" + " ENABLED = false\n"; + const bool desktop_mode = argument::CheckCommandLineArgument(argc, argv, argument::DESKTOP_MODE); const bool no_sound = argument::CheckCommandLineArgument(argc, argv, argument::NO_SOUND); const bool no_manifest = argument::CheckCommandLineArgument(argc, argv, argument::NO_MANIFEST); From 1a043b667266e76105f1eb5ec808f12e584136fe Mon Sep 17 00:00:00 2001 From: Vasily Date: Wed, 26 Dec 2018 22:33:26 +0100 Subject: [PATCH 02/21] Remove code path that would never be executed --- src/main.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index fdb600c..c137975 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -256,5 +256,4 @@ int main(int argc, char *argv[]) { LOG(FATAL) << e.what(); return ReturnErrorCode::GENERAL_FAILURE; } - return ReturnErrorCode::SUCCESS; } From 6d3b5fdf632bc64980418b3efd69d67e6c79698b Mon Sep 17 00:00:00 2001 From: Vasily Date: Wed, 26 Dec 2018 23:01:11 +0100 Subject: [PATCH 03/21] Remove warnings for unreferenced parameters The warnings in dummy functions are preventing the project from being compiled with warnings as errors. There were two options: * Using a define to create a noop (chosen option). * Commenting out the variable name, leaving only the type. The first option was chosen because the second option would leave out information from the IDE and compiler, while the first option wouldn't. The intent is also clearer with the first option, otherwise it would likely be necessary to leave comments with every single parameter that was commented out. --- .../audiomanager/AudioManagerDummy.cpp | 14 ++++++++++++++ .../keyboardinput/KeyboardInputDummy.cpp | 5 +++++ 2 files changed, 19 insertions(+) diff --git a/src/tabcontrollers/audiomanager/AudioManagerDummy.cpp b/src/tabcontrollers/audiomanager/AudioManagerDummy.cpp index 2c3a612..d20016b 100644 --- a/src/tabcontrollers/audiomanager/AudioManagerDummy.cpp +++ b/src/tabcontrollers/audiomanager/AudioManagerDummy.cpp @@ -1,16 +1,22 @@ #include "AudioManagerDummy.h" +// Used to get the compiler to shut up about C4100: unreferenced formal parameter. +#define UNREFERENCED_PARAMETER(P) (P) + // application namespace namespace advsettings { void AudioManagerDummy::init(AudioTabController *controller) { // noop + UNREFERENCED_PARAMETER(controller); } void AudioManagerDummy::setPlaybackDevice(const std::string &id, bool notify) { // noop + UNREFERENCED_PARAMETER(id); + UNREFERENCED_PARAMETER(notify); } std::string AudioManagerDummy::getPlaybackDevName() @@ -26,6 +32,8 @@ std::string AudioManagerDummy::getPlaybackDevId() void AudioManagerDummy::setMirrorDevice(const std::string &id, bool notify) { // noop + UNREFERENCED_PARAMETER(id); + UNREFERENCED_PARAMETER(notify); } bool AudioManagerDummy::isMirrorValid() @@ -50,6 +58,7 @@ float AudioManagerDummy::getMirrorVolume() bool AudioManagerDummy::setMirrorVolume(float value) { + UNREFERENCED_PARAMETER(value); return false; } @@ -60,6 +69,7 @@ bool AudioManagerDummy::getMirrorMuted() bool AudioManagerDummy::setMirrorMuted(bool value) { + UNREFERENCED_PARAMETER(value); return false; } @@ -71,6 +81,8 @@ bool AudioManagerDummy::isMicValid() void AudioManagerDummy::setMicDevice(const std::string &id, bool notify) { // noop + UNREFERENCED_PARAMETER(id); + UNREFERENCED_PARAMETER(notify); } std::string AudioManagerDummy::getMicDevName() @@ -90,6 +102,7 @@ float AudioManagerDummy::getMicVolume() bool AudioManagerDummy::setMicVolume(float value) { + UNREFERENCED_PARAMETER(value); return false; } @@ -100,6 +113,7 @@ bool AudioManagerDummy::getMicMuted() bool AudioManagerDummy::setMicMuted(bool value) { + UNREFERENCED_PARAMETER(value); return false; } diff --git a/src/tabcontrollers/keyboardinput/KeyboardInputDummy.cpp b/src/tabcontrollers/keyboardinput/KeyboardInputDummy.cpp index 69054a9..2b00e33 100644 --- a/src/tabcontrollers/keyboardinput/KeyboardInputDummy.cpp +++ b/src/tabcontrollers/keyboardinput/KeyboardInputDummy.cpp @@ -1,10 +1,14 @@ #include "KeyboardInputDummy.h" +// Used to get the compiler to shut up about C4100: unreferenced formal parameter. +#define UNREFERENCED_PARAMETER(P) (P) + namespace advsettings { void KeyboardInputDummy::sendKeyboardInput(QString input) { // noop + UNREFERENCED_PARAMETER(input); } void KeyboardInputDummy::sendKeyboardEnter() @@ -15,6 +19,7 @@ void KeyboardInputDummy::sendKeyboardEnter() void KeyboardInputDummy::sendKeyboardBackspace(int count) { // noop + UNREFERENCED_PARAMETER(count); } void KeyboardInputDummy::sendKeyboardAltTab() From 629c956618c26f0228beea6719cd3f1461cf9259 Mon Sep 17 00:00:00 2001 From: Vasily Date: Thu, 27 Dec 2018 00:29:08 +0100 Subject: [PATCH 04/21] Change variable being shadowed apperror was shadowing another variable in the scope outside of the if statement, leading to a warning. Adding an underscore changes the var name without changing the meaning. In the future a different structure should probably be chosen for the statements. --- src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index c137975..96bfff1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -58,8 +58,8 @@ void installManifest(bool cleaninstall = false) { if (apperror != vr::VRApplicationError_None) { throw std::runtime_error(std::string("Could not add application manifest: ") + std::string(vr::VRApplications()->GetApplicationsErrorNameFromEnum(apperror))); } else if (!alreadyInstalled || cleaninstall) { - auto apperror = vr::VRApplications()->SetApplicationAutoLaunch(advsettings::OverlayController::applicationKey, true); - if (apperror != vr::VRApplicationError_None) { + auto app_error = vr::VRApplications()->SetApplicationAutoLaunch(advsettings::OverlayController::applicationKey, true); + if (app_error != vr::VRApplicationError_None) { throw std::runtime_error(std::string("Could not set auto start: ") + std::string(vr::VRApplications()->GetApplicationsErrorNameFromEnum(apperror))); } } From 087d2426646325569ad0965ac43ba9b8ddc11449 Mon Sep 17 00:00:00 2001 From: Vasily Date: Thu, 27 Dec 2018 00:53:47 +0100 Subject: [PATCH 05/21] Add compiler switches for warnings as errors Currently with /W3 on MSVC there are no warnings. Clang and g++ are not tested. The "QMAKE_CFLAGS_WARN_ON -= -W3" and "QMAKE_CXXFLAGS_WARN_ON -= -W3" are necessary because if they are not removed in the config, the compiler will give D9025: overriding '/W4' with '/W3' error warnings and not actually use /W4. --- advancedSettings.pro | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/advancedSettings.pro b/advancedSettings.pro index 03159dc..1d180ff 100644 --- a/advancedSettings.pro +++ b/advancedSettings.pro @@ -13,7 +13,24 @@ lessThan(QT_MINOR_VERSION, 6): error("requires Qt 5.6 or higher") TARGET = AdvancedSettings TEMPLATE = app +*msvc* { + #/W4 still has warnings. Including warnings in third party files. + #QMAKE_CFLAGS_WARN_ON -= -W3 + #QMAKE_CXXFLAGS_WARN_ON -= -W3 + #Removing -W3 from both FLAGS is necessary, otherwise compiler will give + #D9025: overriding '/W4' with '/W3' + #QMAKE_CXXFLAGS += /W4 + + QMAKE_CXXFLAGS += /WX +} +*g++* { + QMAKE_CXXFLAGS += -Werror +} + +*clang* { + QMAKE_CXXFLAGS += -Werror +} SOURCES += src/main.cpp\ src/overlaycontroller.cpp \ src/tabcontrollers/AudioTabController.cpp \ From 4904ccaa35922e95c7a703a34356ef22b2566c8f Mon Sep 17 00:00:00 2001 From: Vasily Date: Thu, 27 Dec 2018 01:17:02 +0100 Subject: [PATCH 06/21] Move variables to .cpp file to prevent unused var warning message --- src/tabcontrollers/SteamVRTabController.cpp | 7 +++++++ src/tabcontrollers/SteamVRTabController.h | 6 ------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/tabcontrollers/SteamVRTabController.cpp b/src/tabcontrollers/SteamVRTabController.cpp index e56603e..4643220 100644 --- a/src/tabcontrollers/SteamVRTabController.cpp +++ b/src/tabcontrollers/SteamVRTabController.cpp @@ -10,6 +10,13 @@ namespace vr { // application namespace namespace advsettings { +// openvr's github repo hasn't been updated yet to reflect changes in beta 1477423729. +//static const char* vrsettings_steamvr_allowAsyncReprojection = "allowAsyncReprojection"; +//static const char* vrsettings_steamvr_allowInterleavedReprojection = "allowInterleavedReprojection"; + +static const char* vrsettings_steamvr_supersampleScale = "supersampleScale"; +static const char* vrsettings_steamvr_allowSupersampleFiltering = "allowSupersampleFiltering"; +static const char* vrsettings_compositor_category = "compositor"; void SteamVRTabController::initStage1() { eventLoopTick(); diff --git a/src/tabcontrollers/SteamVRTabController.h b/src/tabcontrollers/SteamVRTabController.h index 79d5ba0..e644cb9 100644 --- a/src/tabcontrollers/SteamVRTabController.h +++ b/src/tabcontrollers/SteamVRTabController.h @@ -3,12 +3,6 @@ #include -// openvr's github repo hasn't been updated yet to reflect changes in beta 1477423729. -//static const char* vrsettings_steamvr_allowAsyncReprojection = "allowAsyncReprojection"; -//static const char* vrsettings_steamvr_allowInterleavedReprojection = "allowInterleavedReprojection"; -static const char* vrsettings_compositor_category = "compositor"; -static const char* vrsettings_steamvr_supersampleScale = "supersampleScale"; -static const char* vrsettings_steamvr_allowSupersampleFiltering = "allowSupersampleFiltering"; class QQuickWindow; From f4feafaa03a88457b5d11c9f4e38009edb8e1668 Mon Sep 17 00:00:00 2001 From: Vasily Date: Thu, 27 Dec 2018 01:26:13 +0100 Subject: [PATCH 07/21] Add parens around statement to banish warning --- src/overlaycontroller.cpp | 4 ++-- src/overlaycontroller.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/overlaycontroller.cpp b/src/overlaycontroller.cpp index f4ded03..a85891f 100644 --- a/src/overlaycontroller.cpp +++ b/src/overlaycontroller.cpp @@ -301,8 +301,8 @@ void OverlayController::OnRenderRequest() { void OverlayController::renderOverlay() { if (!desktopMode) { - // skip rendering if the overlay isn't visible - if (!vr::VROverlay() || !vr::VROverlay()->IsOverlayVisible(m_ulOverlayHandle) && !vr::VROverlay()->IsOverlayVisible(m_ulOverlayThumbnailHandle)) + // skip rendering if the overlay isn't visible + if (!vr::VROverlay() || (!vr::VROverlay()->IsOverlayVisible(m_ulOverlayHandle) && !vr::VROverlay()->IsOverlayVisible(m_ulOverlayThumbnailHandle))) return; m_pRenderControl->polishItems(); m_pRenderControl->sync(); diff --git a/src/overlaycontroller.h b/src/overlaycontroller.h index 257d0db..f47a4a9 100644 --- a/src/overlaycontroller.h +++ b/src/overlaycontroller.h @@ -64,7 +64,7 @@ private: bool dashboardVisible = false; QPoint m_ptLastMouse; - Qt::MouseButtons m_lastMouseButtons = 0; + Qt::MouseButtons m_lastMouseButtons = 0; bool desktopMode; bool noSound; @@ -112,7 +112,7 @@ public: void AddOffsetToCollisionBounds(float offset[3], bool commit = true); void RotateCollisionBounds(float angle, bool commit = true); // around y axis - bool isDesktopMode() { return desktopMode; }; + bool isDesktopMode() { return desktopMode; }; utils::ChaperoneUtils& chaperoneUtils() noexcept { return m_chaperoneUtils; } From e54f2445089b82dbc1b45c1c117f71c904e89b3f Mon Sep 17 00:00:00 2001 From: Vasily Date: Thu, 27 Dec 2018 01:55:49 +0100 Subject: [PATCH 08/21] Fix warnings in AudioTabController Mostly casts and unsigned to signed comparisons. Testing to ensure that the int isn't below 0. If it is, it can't be used in the array later anyway. After we're sure it isn't below 0 it's safe to static_cast(). --- src/tabcontrollers/AudioTabController.cpp | 99 ++++++++++++----------- 1 file changed, 54 insertions(+), 45 deletions(-) diff --git a/src/tabcontrollers/AudioTabController.cpp b/src/tabcontrollers/AudioTabController.cpp index 788abdb..e743566 100644 --- a/src/tabcontrollers/AudioTabController.cpp +++ b/src/tabcontrollers/AudioTabController.cpp @@ -55,10 +55,10 @@ namespace advsettings { if (QFile::exists(QString::fromStdString(notifIconPath))) { vr::VROverlay()->SetOverlayFromFile(m_ulNotificationOverlayHandle, notifIconPath.c_str()); vr::VROverlay()->SetOverlayWidthInMeters(m_ulNotificationOverlayHandle, 0.02f); - vr::HmdMatrix34_t notificationTransform = { - 1.0f, 0.0f, 0.0f, 0.12f, - 0.0f, 1.0f, 0.0f, 0.08f, - 0.0f, 0.0f, 1.0f, -0.3f + vr::HmdMatrix34_t notificationTransform = { + 1.0f, 0.0f, 0.0f, 0.12f, + 0.0f, 1.0f, 0.0f, 0.08f, + 0.0f, 0.0f, 1.0f, -0.3f }; vr::VROverlay()->SetOverlayTransformTrackedDeviceRelative(m_ulNotificationOverlayHandle, vr::k_unTrackedDeviceIndex_Hmd, ¬ificationTransform); } else { @@ -307,25 +307,25 @@ namespace advsettings { emit recordingDeviceListChanged(); } - int AudioTabController::getPlaybackDeviceCount() { - return (int)m_playbackDevices.size(); + int AudioTabController::getPlaybackDeviceCount() { + return static_cast(m_playbackDevices.size()); } - QString AudioTabController::getPlaybackDeviceName(int index) { - if (index < m_playbackDevices.size()) { - return QString::fromStdString(m_playbackDevices[index].second); + QString AudioTabController::getPlaybackDeviceName(int index) { + if (index > 0 && static_cast(index) < m_playbackDevices.size()) { + return QString::fromStdString(m_playbackDevices[static_cast(index)].second); } else { return ""; } } - int AudioTabController::getRecordingDeviceCount() { - return (int)m_recordingDevices.size(); + int AudioTabController::getRecordingDeviceCount() { + return static_cast(m_recordingDevices.size()); } QString AudioTabController::getRecordingDeviceName(int index) { - if (index < m_recordingDevices.size()) { - return QString::fromStdString(m_recordingDevices[index].second); + if (index > 0 && static_cast(index) < m_playbackDevices.size()) { + return QString::fromStdString(m_recordingDevices[static_cast(index)].second); } else { return ""; } @@ -346,15 +346,18 @@ namespace advsettings { void AudioTabController::setPlaybackDeviceIndex(int index, bool notify) { if (index != m_playbackDeviceIndex) { - if (index < m_playbackDevices.size() && index != m_mirrorDeviceIndex) { + if (index > 0 && static_cast(index) < m_playbackDevices.size() && index != m_mirrorDeviceIndex) { vr::EVRSettingsError vrSettingsError; //Applys Audio Switch IN VR - vr::VRSettings()->SetString(vr::k_pch_audio_Section, vr::k_pch_audio_OnPlaybackDevice_String, m_playbackDevices[index].first.c_str(), &vrSettingsError); + vr::VRSettings()->SetString(vr::k_pch_audio_Section, + vr::k_pch_audio_OnPlaybackDevice_String, + m_playbackDevices[static_cast(index)].first.c_str(), + &vrSettingsError); if (vrSettingsError != vr::VRSettingsError_None) { LOG(WARNING) << "Could not write \"" << vr::k_pch_audio_OnPlaybackDevice_String << "\" setting: " << vr::VRSettings()->GetSettingsErrorNameFromEnum(vrSettingsError); } else { - vr::VRSettings()->Sync(); - audioManager->setPlaybackDevice(m_playbackDevices[index].first, notify); + vr::VRSettings()->Sync(); + audioManager->setPlaybackDevice(m_playbackDevices[static_cast(index)].first, notify); } } else if (notify) { emit playbackDeviceIndexChanged(m_playbackDeviceIndex); @@ -373,14 +376,17 @@ namespace advsettings { vr::VRSettings()->Sync(); audioManager->setMirrorDevice("", notify); } - } else if (index < m_playbackDevices.size() && index != m_playbackDeviceIndex && index != m_mirrorDeviceIndex) { - vr::EVRSettingsError vrSettingsError; - vr::VRSettings()->SetString(vr::k_pch_audio_Section, vr::k_pch_audio_OnPlaybackMirrorDevice_String, m_playbackDevices[index].first.c_str(), &vrSettingsError); + } else if (index > 0 && static_cast(index) < m_playbackDevices.size() && index != m_playbackDeviceIndex && index != m_mirrorDeviceIndex) { + vr::EVRSettingsError vrSettingsError; + vr::VRSettings()->SetString(vr::k_pch_audio_Section, + vr::k_pch_audio_OnPlaybackMirrorDevice_String, + m_playbackDevices[static_cast(index)].first.c_str(), + &vrSettingsError); if (vrSettingsError != vr::VRSettingsError_None) { LOG(WARNING) << "Could not write \"" << vr::k_pch_audio_OnPlaybackMirrorDevice_String << "\" setting: " << vr::VRSettings()->GetSettingsErrorNameFromEnum(vrSettingsError); } else { vr::VRSettings()->Sync(); - audioManager->setMirrorDevice(m_playbackDevices[index].first, notify); + audioManager->setMirrorDevice(m_playbackDevices[static_cast(index)].first, notify); } } else if (notify) { emit mirrorDeviceIndexChanged(m_mirrorDeviceIndex); @@ -390,14 +396,14 @@ namespace advsettings { void AudioTabController::setMicDeviceIndex(int index, bool notify) { if (index != m_recordingDeviceIndex) { - if (index < m_recordingDevices.size()) { - vr::EVRSettingsError vrSettingsError; - vr::VRSettings()->SetString(vr::k_pch_audio_Section, vr::k_pch_audio_OnRecordDevice_String, m_recordingDevices[index].first.c_str(), &vrSettingsError); + if (index > 0 && static_cast(index) < m_recordingDevices.size()) { + vr::EVRSettingsError vrSettingsError; + vr::VRSettings()->SetString(vr::k_pch_audio_Section, vr::k_pch_audio_OnRecordDevice_String, m_recordingDevices[static_cast(index)].first.c_str(), &vrSettingsError); if (vrSettingsError != vr::VRSettingsError_None) { LOG(WARNING) << "Could not write \"" << vr::k_pch_audio_OnRecordDevice_String << "\" setting: " << vr::VRSettings()->GetSettingsErrorNameFromEnum(vrSettingsError); } else { - vr::VRSettings()->Sync(); - audioManager->setMicDevice(m_recordingDevices[index].first, notify); + vr::VRSettings()->Sync(); + audioManager->setMicDevice(m_recordingDevices[static_cast(index)].first, notify); } } else if (notify) { emit micDeviceIndexChanged(m_recordingDeviceIndex); @@ -496,8 +502,8 @@ namespace advsettings { auto profileCount = settings->beginReadArray("audioProfiles"); for (int i = 0; i < profileCount; i++) { settings->setArrayIndex(i); - audioProfiles.emplace_back(); - auto& entry = audioProfiles[i]; + audioProfiles.emplace_back(); + auto& entry = audioProfiles[static_cast(i)]; entry.profileName = settings->value("profileName").toString().toStdString(); entry.playbackName = settings->value("playbackName").toString().toStdString(); entry.micName = settings->value("micName").toString().toStdString(); @@ -528,9 +534,9 @@ namespace advsettings { auto settings = OverlayController::appSettings(); settings->beginGroup(getSettingsName()); settings->beginWriteArray("audioProfiles"); - unsigned i = 0; - for (auto& p : audioProfiles) { - settings->setArrayIndex(i); + int i = 0; + for (auto& p : audioProfiles) { + settings->setArrayIndex(i); settings->setValue("profileName", QString::fromStdString(p.profileName)); settings->setValue("playbackName", QString::fromStdString(p.playbackName)); settings->setValue("micName", QString::fromStdString(p.micName)); @@ -657,9 +663,9 @@ namespace advsettings { } - unsigned AudioTabController::getAudioProfileCount() { - return (unsigned)audioProfiles.size(); - } + unsigned AudioTabController::getAudioProfileCount() { + return static_cast(audioProfiles.size()); + } QString AudioTabController::getAudioProfileName(unsigned index) { if (index < audioProfiles.size()) { @@ -676,28 +682,31 @@ namespace advsettings { description: Gets proper index value for selecting specific devices. */ - int AudioTabController::getPlaybackIndex(std::string str) { - for (int i = 0; i < m_playbackDevices.size(); i++) { - if (str.compare(m_playbackDevices[i].second)==0) { - return i; + int AudioTabController::getPlaybackIndex(std::string str) { + //Unsigned to avoid two casts. i won't be negative because we only increment it. + for (unsigned int i = 0; i < m_playbackDevices.size(); i++) { + if (str.compare(m_playbackDevices[i].second)==0) { + return static_cast(i); } } return m_playbackDeviceIndex; } - int AudioTabController::getRecordingIndex(std::string str) { - for (int i = 0; i < m_recordingDevices.size(); i++) { - if (str.compare(m_recordingDevices[i].second) == 0) { - return i; + int AudioTabController::getRecordingIndex(std::string str) { + //Unsigned to avoid two casts. i won't be negative because we only increment it. + for (unsigned int i = 0; i < m_recordingDevices.size(); i++) { + if (str.compare(m_recordingDevices[i].second) == 0) { + return static_cast(i); } } return m_recordingDeviceIndex; } int AudioTabController::getMirrorIndex(std::string str) { - for (int i = 0; i < m_playbackDevices.size(); i++) { - if (str.compare(m_playbackDevices[i].second) == 0) { - return i; + //Unsigned to avoid two casts. i won't be negative because we only increment it. + for (unsigned int i = 0; i < m_playbackDevices.size(); i++) { + if (str.compare(m_playbackDevices[i].second) == 0) { + return static_cast(i); } } return -1; From 9a2c388a1caee6eaee2715af0958625384a4fba4 Mon Sep 17 00:00:00 2001 From: Vasily Date: Thu, 27 Dec 2018 12:14:07 +0100 Subject: [PATCH 09/21] Solve initialization bug in MOveCenterTabController MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GCC gave error ../src/tabcontrollers/MoveCenterTabController.cpp:57:67: error: operation on ‘((advsettings::MoveCenterTabController*)this)->advsettings::MoveCenterTabController::lastMoveButtonClick[0]’ may be undefined [-Werror=sequence-point] Because assigning a value to itself twice is undefined behavior. It is highly likely that intended behavior was to initialize both array members to the same value at once. --- src/tabcontrollers/MoveCenterTabController.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tabcontrollers/MoveCenterTabController.cpp b/src/tabcontrollers/MoveCenterTabController.cpp index 8641185..a6a6d13 100644 --- a/src/tabcontrollers/MoveCenterTabController.cpp +++ b/src/tabcontrollers/MoveCenterTabController.cpp @@ -54,7 +54,7 @@ void MoveCenterTabController::initStage1() { m_lockZToggle = value.toBool(); } settings->endGroup(); - lastMoveButtonClick[0] = lastMoveButtonClick[0] = clock::now(); + lastMoveButtonClick[0] = lastMoveButtonClick[1] = clock::now(); } void MoveCenterTabController::initStage2(OverlayController * parent, QQuickWindow * widget) { From f32c91fe030b06a44bb9982f984292aefddacf6f Mon Sep 17 00:00:00 2001 From: Vasily Date: Thu, 27 Dec 2018 12:37:55 +0100 Subject: [PATCH 10/21] Fix GCC warning about unused value Casting to void should shut up GCC about error: statement has no effect [-Werror=unused-value] static_cast() is possible for all current types. Supposedly an old C style cast could also be used, but they should not be used in modern C++ code. --- src/tabcontrollers/audiomanager/AudioManagerDummy.cpp | 3 ++- src/tabcontrollers/keyboardinput/KeyboardInputDummy.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/tabcontrollers/audiomanager/AudioManagerDummy.cpp b/src/tabcontrollers/audiomanager/AudioManagerDummy.cpp index d20016b..a36781b 100644 --- a/src/tabcontrollers/audiomanager/AudioManagerDummy.cpp +++ b/src/tabcontrollers/audiomanager/AudioManagerDummy.cpp @@ -1,7 +1,8 @@ #include "AudioManagerDummy.h" // Used to get the compiler to shut up about C4100: unreferenced formal parameter. -#define UNREFERENCED_PARAMETER(P) (P) +// The cast is to get GCC to shut up about it. +#define UNREFERENCED_PARAMETER(P) static_cast((P)) // application namespace namespace advsettings { diff --git a/src/tabcontrollers/keyboardinput/KeyboardInputDummy.cpp b/src/tabcontrollers/keyboardinput/KeyboardInputDummy.cpp index 2b00e33..83cd526 100644 --- a/src/tabcontrollers/keyboardinput/KeyboardInputDummy.cpp +++ b/src/tabcontrollers/keyboardinput/KeyboardInputDummy.cpp @@ -1,7 +1,8 @@ #include "KeyboardInputDummy.h" // Used to get the compiler to shut up about C4100: unreferenced formal parameter. -#define UNREFERENCED_PARAMETER(P) (P) +// The cast is to get GCC to shut up about it. +#define UNREFERENCED_PARAMETER(P) static_cast((P)) namespace advsettings { From 0d6917566ebfc270573cc0e143f70e99f04eb94b Mon Sep 17 00:00:00 2001 From: Vasily Date: Thu, 27 Dec 2018 14:04:14 +0100 Subject: [PATCH 11/21] Add clang switch to ignore third party warnings The --system-header-prefix=third-party treats all includes with a path matching third-party as system files, meaning they won't show warnings. --- advancedSettings.pro | 1 + 1 file changed, 1 insertion(+) diff --git a/advancedSettings.pro b/advancedSettings.pro index 1d180ff..6cbf415 100644 --- a/advancedSettings.pro +++ b/advancedSettings.pro @@ -30,6 +30,7 @@ TEMPLATE = app *clang* { QMAKE_CXXFLAGS += -Werror + QMAKE_CXXFLAGS += --system-header-prefix=third-party } SOURCES += src/main.cpp\ src/overlaycontroller.cpp \ From 6c4541018ded6f73bc9730da933fa0e717214058 Mon Sep 17 00:00:00 2001 From: Vasily Date: Thu, 27 Dec 2018 14:05:37 +0100 Subject: [PATCH 12/21] Change NULL to nullptr --- src/tabcontrollers/keyboardinput/KeyboardInputWindows.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tabcontrollers/keyboardinput/KeyboardInputWindows.cpp b/src/tabcontrollers/keyboardinput/KeyboardInputWindows.cpp index aafa129..2ea948b 100644 --- a/src/tabcontrollers/keyboardinput/KeyboardInputWindows.cpp +++ b/src/tabcontrollers/keyboardinput/KeyboardInputWindows.cpp @@ -22,12 +22,12 @@ void sendKeyboardInputRaw(int inputCount, LPINPUT input) { char *err; auto errCode = GetLastError(); if (!FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, - NULL, + nullptr, errCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // default language (LPTSTR)&err, 0, - NULL)){ + nullptr)){ LOG(ERROR) << "Error calling SendInput(): Could not get error message (" << errCode << ")"; } else { LOG(ERROR) << "Error calling SendInput(): " << err; From 450bf91db69bf81791fc53a9aebfa4c8ab885e7e Mon Sep 17 00:00:00 2001 From: Vasily Date: Thu, 27 Dec 2018 14:13:27 +0100 Subject: [PATCH 13/21] Resolve implicit unsigned/signed casts --- .../keyboardinput/KeyboardInputWindows.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/tabcontrollers/keyboardinput/KeyboardInputWindows.cpp b/src/tabcontrollers/keyboardinput/KeyboardInputWindows.cpp index 2ea948b..fb08ccf 100644 --- a/src/tabcontrollers/keyboardinput/KeyboardInputWindows.cpp +++ b/src/tabcontrollers/keyboardinput/KeyboardInputWindows.cpp @@ -18,7 +18,7 @@ void fillKiStruct(INPUT& ip, WORD scanCode, bool keyup) { }; void sendKeyboardInputRaw(int inputCount, LPINPUT input) { - if (!SendInput(inputCount, input, sizeof(INPUT))) { + if ((inputCount > 0) && !SendInput(static_cast(inputCount), input, sizeof(INPUT))) { char *err; auto errCode = GetLastError(); if (!FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, @@ -39,8 +39,8 @@ void KeyboardInputWindows::sendKeyboardInput(QString input) { int len = input.length(); if (len > 0) { - LPINPUT ips = new INPUT[len * 5 + 3]; - unsigned ii = 0; + LPINPUT ips = new INPUT[static_cast(len) * 5 + 3]; + int ii = 0; bool shiftPressed = false; bool ctrlPressed = false; bool altPressed = false; @@ -106,7 +106,8 @@ void KeyboardInputWindows::sendKeyboardEnter() void KeyboardInputWindows::sendKeyboardBackspace(int count) { if (count > 0) { - LPINPUT ips = new INPUT[count * 2]; + // We ensure that count is nonnegative, therefore safe cast. + LPINPUT ips = new INPUT[static_cast(count) * 2]; for (int i = 0; i < count; i++) { fillKiStruct(ips[2 * i], VK_BACK, false); fillKiStruct(ips[2 * i + 1], VK_BACK, true); From b452e6845635e7b230e03bf6fa7870ba70f69444 Mon Sep 17 00:00:00 2001 From: Vasily Date: Thu, 27 Dec 2018 14:14:49 +0100 Subject: [PATCH 14/21] Fix minor memory leaks The delete keyword only calls a single destructor, the delete[] keyword calls as many destructors as there are members of the array. --- src/tabcontrollers/keyboardinput/KeyboardInputWindows.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/tabcontrollers/keyboardinput/KeyboardInputWindows.cpp b/src/tabcontrollers/keyboardinput/KeyboardInputWindows.cpp index fb08ccf..b4f7b6e 100644 --- a/src/tabcontrollers/keyboardinput/KeyboardInputWindows.cpp +++ b/src/tabcontrollers/keyboardinput/KeyboardInputWindows.cpp @@ -89,7 +89,7 @@ void KeyboardInputWindows::sendKeyboardInput(QString input) } sendKeyboardInputRaw(ii, ips); - delete ips; + delete[] ips; } } @@ -100,7 +100,7 @@ void KeyboardInputWindows::sendKeyboardEnter() fillKiStruct(ips[1], VK_RETURN, true); sendKeyboardInputRaw(2, ips); - delete ips; + delete[] ips; } void KeyboardInputWindows::sendKeyboardBackspace(int count) @@ -114,7 +114,7 @@ void KeyboardInputWindows::sendKeyboardBackspace(int count) } sendKeyboardInputRaw(count * 2, ips); - delete ips; + delete[] ips; } } @@ -128,7 +128,7 @@ void KeyboardInputWindows::sendKeyboardAltTab() fillKiStruct(ips[3], VK_MENU, true); sendKeyboardInputRaw(4, ips); - delete ips; + delete[] ips; } } From d9a4da5f5d38dc8c308441802f85ad4f7e357cec Mon Sep 17 00:00:00 2001 From: Vasily Date: Thu, 27 Dec 2018 14:18:03 +0100 Subject: [PATCH 15/21] Change C style cast to reinterpret_cast static_cast won't cast between pointer types, reinterpret_cast will. --- src/tabcontrollers/keyboardinput/KeyboardInputWindows.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tabcontrollers/keyboardinput/KeyboardInputWindows.cpp b/src/tabcontrollers/keyboardinput/KeyboardInputWindows.cpp index b4f7b6e..471f27a 100644 --- a/src/tabcontrollers/keyboardinput/KeyboardInputWindows.cpp +++ b/src/tabcontrollers/keyboardinput/KeyboardInputWindows.cpp @@ -25,7 +25,7 @@ void sendKeyboardInputRaw(int inputCount, LPINPUT input) { nullptr, errCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // default language - (LPTSTR)&err, + reinterpret_cast(&err), 0, nullptr)){ LOG(ERROR) << "Error calling SendInput(): Could not get error message (" << errCode << ")"; From e7e7272d5228a845595ae0b54966140ed5ed5da6 Mon Sep 17 00:00:00 2001 From: Vasily Date: Thu, 27 Dec 2018 14:23:54 +0100 Subject: [PATCH 16/21] Fix memory leaks as result of missing delete[] The delete keyword only calls a single destructor, delete[] calls as many as there are members in the array. --- src/overlaycontroller.cpp | 4 ++-- src/tabcontrollers/ChaperoneTabController.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/overlaycontroller.cpp b/src/overlaycontroller.cpp index a85891f..c0195dc 100644 --- a/src/overlaycontroller.cpp +++ b/src/overlaycontroller.cpp @@ -593,7 +593,7 @@ void OverlayController::AddOffsetToCollisionBounds(float offset[3], bool commit) } } vr::VRChaperoneSetup()->SetWorkingCollisionBoundsInfo(collisionBounds, collisionBoundsCount); - delete collisionBounds; + delete[] collisionBounds; } if (commit && collisionBoundsCount > 0) { vr::VRChaperoneSetup()->CommitWorkingCopy(vr::EChaperoneConfigFile_Live); @@ -621,7 +621,7 @@ void OverlayController::RotateCollisionBounds(float angle, bool commit) { } } vr::VRChaperoneSetup()->SetWorkingCollisionBoundsInfo(collisionBounds, collisionBoundsCount); - delete collisionBounds; + delete[] collisionBounds; } if (commit && collisionBoundsCount > 0) { vr::VRChaperoneSetup()->CommitWorkingCopy(vr::EChaperoneConfigFile_Live); diff --git a/src/tabcontrollers/ChaperoneTabController.cpp b/src/tabcontrollers/ChaperoneTabController.cpp index 92572bf..ce706ef 100644 --- a/src/tabcontrollers/ChaperoneTabController.cpp +++ b/src/tabcontrollers/ChaperoneTabController.cpp @@ -486,7 +486,7 @@ void ChaperoneTabController::setHeight(float value, bool notify) { } vr::VRChaperoneSetup()->SetWorkingCollisionBoundsInfo(collisionBounds, collisionBoundsCount); vr::VRChaperoneSetup()->CommitWorkingCopy(vr::EChaperoneConfigFile_Live); - delete collisionBounds; + delete[] collisionBounds; } if (notify) { emit heightChanged(m_fadeDistance); @@ -1006,7 +1006,7 @@ float ChaperoneTabController::getBoundsMaxY() { result = collisionBounds[b].vCorners[ci].v[1]; } } - delete collisionBounds; + delete[] collisionBounds; } return result; } From f42c481308e5a92cb6e86f8c3a351b248e5b0d59 Mon Sep 17 00:00:00 2001 From: Vasily Date: Thu, 27 Dec 2018 14:29:22 +0100 Subject: [PATCH 17/21] Add brackets around intialization of 2D array inside struct 2 brackets are necessary because it's initialization of a struct, intializing an 3 member array of 4 floats. --- src/tabcontrollers/AudioTabController.cpp | 12 ++++++------ src/tabcontrollers/UtilitiesTabController.cpp | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/tabcontrollers/AudioTabController.cpp b/src/tabcontrollers/AudioTabController.cpp index e743566..84c89d4 100644 --- a/src/tabcontrollers/AudioTabController.cpp +++ b/src/tabcontrollers/AudioTabController.cpp @@ -54,12 +54,12 @@ namespace advsettings { std::string notifIconPath = QApplication::applicationDirPath().toStdString() + "/res/qml/ptt_notification.png"; if (QFile::exists(QString::fromStdString(notifIconPath))) { vr::VROverlay()->SetOverlayFromFile(m_ulNotificationOverlayHandle, notifIconPath.c_str()); - vr::VROverlay()->SetOverlayWidthInMeters(m_ulNotificationOverlayHandle, 0.02f); - vr::HmdMatrix34_t notificationTransform = { - 1.0f, 0.0f, 0.0f, 0.12f, - 0.0f, 1.0f, 0.0f, 0.08f, - 0.0f, 0.0f, 1.0f, -0.3f - }; + vr::VROverlay()->SetOverlayWidthInMeters(m_ulNotificationOverlayHandle, 0.02f); + vr::HmdMatrix34_t notificationTransform = {{ + {1.0f, 0.0f, 0.0f, 0.12f}, + {0.0f, 1.0f, 0.0f, 0.08f}, + {0.0f, 0.0f, 1.0f, -0.3f} + }}; vr::VROverlay()->SetOverlayTransformTrackedDeviceRelative(m_ulNotificationOverlayHandle, vr::k_unTrackedDeviceIndex_Hmd, ¬ificationTransform); } else { LOG(ERROR) << "Could not find notification icon \"" << notifIconPath << "\""; diff --git a/src/tabcontrollers/UtilitiesTabController.cpp b/src/tabcontrollers/UtilitiesTabController.cpp index 4cd203e..705999a 100644 --- a/src/tabcontrollers/UtilitiesTabController.cpp +++ b/src/tabcontrollers/UtilitiesTabController.cpp @@ -210,11 +210,11 @@ namespace advsettings { if (QFile::exists(QString::fromStdString(batteryIconPath))) { vr::VROverlay()->SetOverlayFromFile(handle, batteryIconPath.c_str()); vr::VROverlay()->SetOverlayWidthInMeters(handle, 0.05f); - vr::HmdMatrix34_t notificationTransform = { - 1.0f, 0.0f, 0.0f, 0.00f, - 0.0f, -1.0f, 0.0f, 0.01f, - 0.0f, 0.0f, -1.0f, -0.013f - }; + vr::HmdMatrix34_t notificationTransform = {{ + {1.0f, 0.0f, 0.0f, 0.00f}, + {0.0f, -1.0f, 0.0f, 0.01f}, + {0.0f, 0.0f, -1.0f, -0.013f} + }}; vr::VROverlay()->SetOverlayTransformTrackedDeviceRelative(handle, index, ¬ificationTransform); LOG(INFO) << "Created battery overlay for device " << index; } else { From 412e56fa1154222b3b536f90171bf6d708f3cb1b Mon Sep 17 00:00:00 2001 From: Vasily Date: Thu, 27 Dec 2018 16:27:31 +0100 Subject: [PATCH 18/21] Add switches for msvc-clang The clang frontend for MSVC does not allow the same type of switches that regular clang does, therefore we need logic to gate off msvc-clang. --- advancedSettings.pro | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/advancedSettings.pro b/advancedSettings.pro index 6cbf415..497199d 100644 --- a/advancedSettings.pro +++ b/advancedSettings.pro @@ -22,14 +22,25 @@ TEMPLATE = app #QMAKE_CXXFLAGS += /W4 QMAKE_CXXFLAGS += /WX + + #The MSVC frontend for clang does not understand /external + !*clang-msvc{ + #external:anglebrackets suppresses warnings made in #includes + #made with angle brackets, like #include , but will + #still report for includes done with quotes. + QMAKE_CXXFLAGS += /experimental:external /external:anglebrackets + } } *g++* { QMAKE_CXXFLAGS += -Werror } -*clang* { +#Look for anything clang that is not clang-msvc, since it does not +#allow all the same switches as regular clang. +*clang|*clang-g++|*clang-libc++ { QMAKE_CXXFLAGS += -Werror + #All includes from the third-party directory will not warn. QMAKE_CXXFLAGS += --system-header-prefix=third-party } SOURCES += src/main.cpp\ From b097908b124c2f7657c657bb9282a6aa6cde61a4 Mon Sep 17 00:00:00 2001 From: Vasily Date: Thu, 27 Dec 2018 18:27:27 +0100 Subject: [PATCH 19/21] Rename parameters shadowing class members Parameters with the same name as class members are ripe for introducing bugs. The fact that the "this->" syntax is optional creates confusion for maintaining programmers who can only guess at the intention. --- src/tabcontrollers/AccessibilityTabController.cpp | 6 +++--- src/tabcontrollers/AudioTabController.cpp | 6 +++--- src/tabcontrollers/ChaperoneTabController.cpp | 6 +++--- src/tabcontrollers/FixFloorTabController.cpp | 6 +++--- src/tabcontrollers/MoveCenterTabController.cpp | 6 +++--- src/tabcontrollers/ReviveTabController.cpp | 6 +++--- src/tabcontrollers/SettingsTabController.cpp | 6 +++--- src/tabcontrollers/StatisticsTabController.cpp | 6 +++--- src/tabcontrollers/SteamVRTabController.cpp | 6 +++--- src/tabcontrollers/UtilitiesTabController.cpp | 6 +++--- src/tabcontrollers/audiomanager/AudioManagerWindows.cpp | 4 ++-- 11 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/tabcontrollers/AccessibilityTabController.cpp b/src/tabcontrollers/AccessibilityTabController.cpp index 6c8e34b..c2dfa9c 100644 --- a/src/tabcontrollers/AccessibilityTabController.cpp +++ b/src/tabcontrollers/AccessibilityTabController.cpp @@ -19,9 +19,9 @@ void AccessibilityTabController::initStage1() { reloadPttConfig(); } -void AccessibilityTabController::initStage2(OverlayController * parent, QQuickWindow * widget) { - this->parent = parent; - this->widget = widget; +void AccessibilityTabController::initStage2(OverlayController * var_parent, QQuickWindow * var_widget) { + this->parent = var_parent; + this->widget = var_widget; } void AccessibilityTabController::setTrackingUniverse(int value) { diff --git a/src/tabcontrollers/AudioTabController.cpp b/src/tabcontrollers/AudioTabController.cpp index 84c89d4..ab79030 100644 --- a/src/tabcontrollers/AudioTabController.cpp +++ b/src/tabcontrollers/AudioTabController.cpp @@ -44,9 +44,9 @@ namespace advsettings { } - void AudioTabController::initStage2(OverlayController * parent, QQuickWindow * widget) { - this->parent = parent; - this->widget = widget; + void AudioTabController::initStage2(OverlayController * var_parent, QQuickWindow * var_widget) { + this->parent = var_parent; + this->widget = var_widget; std::string notifKey = std::string(OverlayController::applicationKey) + ".pptnotification"; vr::VROverlayError overlayError = vr::VROverlay()->CreateOverlay(notifKey.c_str(), notifKey.c_str(), &m_ulNotificationOverlayHandle); diff --git a/src/tabcontrollers/ChaperoneTabController.cpp b/src/tabcontrollers/ChaperoneTabController.cpp index ce706ef..f286cd9 100644 --- a/src/tabcontrollers/ChaperoneTabController.cpp +++ b/src/tabcontrollers/ChaperoneTabController.cpp @@ -32,9 +32,9 @@ void ChaperoneTabController::initStage1() { } -void ChaperoneTabController::initStage2(OverlayController * parent, QQuickWindow * widget) { - this->parent = parent; - this->widget = widget; +void ChaperoneTabController::initStage2(OverlayController * var_parent, QQuickWindow * var_widget) { + this->parent = var_parent; + this->widget = var_widget; } diff --git a/src/tabcontrollers/FixFloorTabController.cpp b/src/tabcontrollers/FixFloorTabController.cpp index 8ac480d..34d2e69 100644 --- a/src/tabcontrollers/FixFloorTabController.cpp +++ b/src/tabcontrollers/FixFloorTabController.cpp @@ -9,9 +9,9 @@ namespace advsettings { void FixFloorTabController::initStage1() { } -void FixFloorTabController::initStage2(OverlayController * parent, QQuickWindow * widget) { - this->parent = parent; - this->widget = widget; +void FixFloorTabController::initStage2(OverlayController * var_parent, QQuickWindow * var_widget) { + this->parent = var_parent; + this->widget = var_widget; } void FixFloorTabController::eventLoopTick(vr::TrackedDevicePose_t* devicePoses) { diff --git a/src/tabcontrollers/MoveCenterTabController.cpp b/src/tabcontrollers/MoveCenterTabController.cpp index a6a6d13..1dec969 100644 --- a/src/tabcontrollers/MoveCenterTabController.cpp +++ b/src/tabcontrollers/MoveCenterTabController.cpp @@ -57,9 +57,9 @@ void MoveCenterTabController::initStage1() { lastMoveButtonClick[0] = lastMoveButtonClick[1] = clock::now(); } -void MoveCenterTabController::initStage2(OverlayController * parent, QQuickWindow * widget) { - this->parent = parent; - this->widget = widget; +void MoveCenterTabController::initStage2(OverlayController * var_parent, QQuickWindow * var_widget) { + this->parent = var_parent; + this->widget = var_widget; } diff --git a/src/tabcontrollers/ReviveTabController.cpp b/src/tabcontrollers/ReviveTabController.cpp index 58994d8..78c7d80 100644 --- a/src/tabcontrollers/ReviveTabController.cpp +++ b/src/tabcontrollers/ReviveTabController.cpp @@ -167,9 +167,9 @@ namespace advsettings { } } - void ReviveTabController::initStage2(OverlayController * parent, QQuickWindow * widget) { - this->parent = parent; - this->widget = widget; + void ReviveTabController::initStage2(OverlayController * var_parent, QQuickWindow * var_widget) { + this->parent = var_parent; + this->widget = var_widget; } void ReviveTabController::eventLoopTick() { diff --git a/src/tabcontrollers/SettingsTabController.cpp b/src/tabcontrollers/SettingsTabController.cpp index 82bde48..ae747c5 100644 --- a/src/tabcontrollers/SettingsTabController.cpp +++ b/src/tabcontrollers/SettingsTabController.cpp @@ -17,9 +17,9 @@ void SettingsTabController::initStage1() { } } -void SettingsTabController::initStage2(OverlayController * parent, QQuickWindow * widget) { - this->parent = parent; - this->widget = widget; +void SettingsTabController::initStage2(OverlayController * var_parent, QQuickWindow * var_widget) { + this->parent = var_parent; + this->widget = var_widget; } void SettingsTabController::eventLoopTick() { diff --git a/src/tabcontrollers/StatisticsTabController.cpp b/src/tabcontrollers/StatisticsTabController.cpp index 2195af5..6ee28d6 100644 --- a/src/tabcontrollers/StatisticsTabController.cpp +++ b/src/tabcontrollers/StatisticsTabController.cpp @@ -8,9 +8,9 @@ namespace advsettings { void StatisticsTabController::initStage1() { } -void StatisticsTabController::initStage2(OverlayController * parent, QQuickWindow * widget) { - this->parent = parent; - this->widget = widget; +void StatisticsTabController::initStage2(OverlayController * var_parent, QQuickWindow * var_widget) { + this->parent = var_parent; + this->widget = var_widget; } void StatisticsTabController::eventLoopTick(vr::TrackedDevicePose_t* devicePoses, float leftSpeed, float rightSpeed) { diff --git a/src/tabcontrollers/SteamVRTabController.cpp b/src/tabcontrollers/SteamVRTabController.cpp index 4643220..d3cfaba 100644 --- a/src/tabcontrollers/SteamVRTabController.cpp +++ b/src/tabcontrollers/SteamVRTabController.cpp @@ -24,9 +24,9 @@ void SteamVRTabController::initStage1() { } -void SteamVRTabController::initStage2(OverlayController * parent, QQuickWindow * widget) { - this->parent = parent; - this->widget = widget; +void SteamVRTabController::initStage2(OverlayController * var_parent, QQuickWindow * var_widget) { + this->parent = var_parent; + this->widget = var_widget; } diff --git a/src/tabcontrollers/UtilitiesTabController.cpp b/src/tabcontrollers/UtilitiesTabController.cpp index 705999a..c83cfd3 100644 --- a/src/tabcontrollers/UtilitiesTabController.cpp +++ b/src/tabcontrollers/UtilitiesTabController.cpp @@ -48,9 +48,9 @@ namespace advsettings { } - void UtilitiesTabController::initStage2(OverlayController * parent, QQuickWindow * widget) { - this->parent = parent; - this->widget = widget; + void UtilitiesTabController::initStage2(OverlayController * var_parent, QQuickWindow * var_widget) { + this->parent = var_parent; + this->widget = var_widget; } void UtilitiesTabController::sendKeyboardInput(QString input) { diff --git a/src/tabcontrollers/audiomanager/AudioManagerWindows.cpp b/src/tabcontrollers/audiomanager/AudioManagerWindows.cpp index 7e41a32..89a1c06 100644 --- a/src/tabcontrollers/audiomanager/AudioManagerWindows.cpp +++ b/src/tabcontrollers/audiomanager/AudioManagerWindows.cpp @@ -31,7 +31,7 @@ AudioManagerWindows::~AudioManagerWindows() { audioDeviceEnumerator->Release(); } -void AudioManagerWindows::init(AudioTabController* controller) { +void AudioManagerWindows::init(AudioTabController* var_controller) { std::lock_guard lock(_mutex); audioDeviceEnumerator = getAudioDeviceEnumerator(); if (!audioDeviceEnumerator) { @@ -47,7 +47,7 @@ void AudioManagerWindows::init(AudioTabController* controller) { } else { LOG(WARNING) << "Could not find a default recording device."; } - this->controller = controller; + this->controller = var_controller; audioDeviceEnumerator->RegisterEndpointNotificationCallback((IMMNotificationClient*)this); policyConfig = getPolicyConfig(); if (!policyConfig) { From e8cda901d1edcc5599c43720fd4fc6689b40bad5 Mon Sep 17 00:00:00 2001 From: Vasily Date: Thu, 27 Dec 2018 18:42:29 +0100 Subject: [PATCH 20/21] Rename local var that shadows member var Notice that the class has an identical var that is used in several places. It is unknown if the original programmer intended to use the member var in this function, but what is actually being done is a new var being created, changed and returned. This may not respect the original intention, but it does preserve the original mechanics. --- .../audiomanager/AudioManagerWindows.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/tabcontrollers/audiomanager/AudioManagerWindows.cpp b/src/tabcontrollers/audiomanager/AudioManagerWindows.cpp index 89a1c06..b05fcf5 100644 --- a/src/tabcontrollers/audiomanager/AudioManagerWindows.cpp +++ b/src/tabcontrollers/audiomanager/AudioManagerWindows.cpp @@ -277,20 +277,20 @@ IMMDeviceEnumerator* AudioManagerWindows::getAudioDeviceEnumerator() { } IPolicyConfig * AudioManagerWindows::getPolicyConfig() { - IPolicyConfig* policyConfig = nullptr; + IPolicyConfig* var_policyConfig = nullptr; // for Win 10 - auto hr = CoCreateInstance(__uuidof(CPolicyConfigClient), NULL, CLSCTX_INPROC, IID_IPolicyConfig2, (LPVOID *)&policyConfig); + auto hr = CoCreateInstance(__uuidof(CPolicyConfigClient), NULL, CLSCTX_INPROC, IID_IPolicyConfig2, (LPVOID *)&var_policyConfig); if (hr != S_OK) { - hr = CoCreateInstance(__uuidof(CPolicyConfigClient), NULL, CLSCTX_INPROC, IID_IPolicyConfig1, (LPVOID *)&policyConfig); + hr = CoCreateInstance(__uuidof(CPolicyConfigClient), NULL, CLSCTX_INPROC, IID_IPolicyConfig1, (LPVOID *)&var_policyConfig); } // for Win Vista, 7, 8, 8.1 if (hr != S_OK) { - hr = CoCreateInstance(__uuidof(CPolicyConfigClient), NULL, CLSCTX_INPROC, IID_IPolicyConfig0, (LPVOID *)&policyConfig); + hr = CoCreateInstance(__uuidof(CPolicyConfigClient), NULL, CLSCTX_INPROC, IID_IPolicyConfig0, (LPVOID *)&var_policyConfig); } if (hr != S_OK) { return nullptr; } else { - return policyConfig; + return var_policyConfig; } } From f1f39ac1a81e6c2724d5dfa3e97a8c89c2e5f64f Mon Sep 17 00:00:00 2001 From: Vasily Date: Thu, 27 Dec 2018 20:09:48 +0100 Subject: [PATCH 21/21] Add /WX switches for MSVC compilers, except clang-msvc Clang-msvc has problems with around 400 "-Wexpansion-to-defined" errors in easylogging++.h. No flags seem to be able to disable this error. Clang-cl is generally in an awkward halfway place between clang and msvc. Msvc has problems with C4127 "conditional expression is constant" in the "qvarlengtharray.h", hence it being disabled with /wd4127. Neither msvc* compiler has proper support for disabling errors in specific files. It's either QMAKE magic or waiting for proper support. --- advancedSettings.pro | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/advancedSettings.pro b/advancedSettings.pro index 497199d..9458a0f 100644 --- a/advancedSettings.pro +++ b/advancedSettings.pro @@ -14,21 +14,14 @@ TARGET = AdvancedSettings TEMPLATE = app *msvc* { - #/W4 still has warnings. Including warnings in third party files. - #QMAKE_CFLAGS_WARN_ON -= -W3 - #QMAKE_CXXFLAGS_WARN_ON -= -W3 #Removing -W3 from both FLAGS is necessary, otherwise compiler will give #D9025: overriding '/W4' with '/W3' - #QMAKE_CXXFLAGS += /W4 + QMAKE_CFLAGS_WARN_ON -= -W3 + QMAKE_CXXFLAGS_WARN_ON -= -W3 + QMAKE_CXXFLAGS += /W4 /wd4127 - QMAKE_CXXFLAGS += /WX - - #The MSVC frontend for clang does not understand /external !*clang-msvc{ - #external:anglebrackets suppresses warnings made in #includes - #made with angle brackets, like #include , but will - #still report for includes done with quotes. - QMAKE_CXXFLAGS += /experimental:external /external:anglebrackets + QMAKE_CXXFLAGS += /WX } }