From ed7703c60ca7da9e67bee8e46e2811e87cfdadaf Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Fri, 24 Sep 2021 14:57:30 +0300 Subject: [PATCH] Clang warnings. --- src/app/puzzle/vpmainwindow.cpp | 4 ++-- src/app/tape/tmainwindow.cpp | 4 ++-- src/app/valentina/mainwindow.cpp | 4 ++-- src/libs/fervor/fvupdater.cpp | 12 ++++++------ src/libs/ifc/xml/vabstractconverter.h | 6 +----- src/libs/vmisc/customevents.h | 20 ++++++++++++++++++++ src/libs/vmisc/projectversion.cpp | 4 ---- src/libs/vmisc/projectversion.h | 23 ++++++++++++----------- src/libs/vmisc/vcommonsettings.cpp | 6 +++--- src/libs/vmisc/vcommonsettings.h | 4 ++-- 10 files changed, 50 insertions(+), 37 deletions(-) diff --git a/src/app/puzzle/vpmainwindow.cpp b/src/app/puzzle/vpmainwindow.cpp index de7701e72..b45a5eb42 100644 --- a/src/app/puzzle/vpmainwindow.cpp +++ b/src/app/puzzle/vpmainwindow.cpp @@ -1711,7 +1711,7 @@ void VPMainWindow::ReadSettings() { restoreGeometry(settings->GetGeometry()); restoreState(settings->GetWindowState()); - restoreState(settings->GetToolbarsState(), APP_VERSION); + restoreState(settings->GetToolbarsState(), AppVersion()); // Text under tool buton icon ToolBarStyles(); @@ -1737,7 +1737,7 @@ void VPMainWindow::WriteSettings() VPSettings *settings = VPApplication::VApp()->PuzzleSettings(); settings->SetGeometry(saveGeometry()); settings->SetWindowState(saveState()); - settings->SetToolbarsState(saveState(APP_VERSION)); + settings->SetToolbarsState(saveState(AppVersion())); settings->SetDockWidgetPropertiesActive(ui->dockWidgetProperties->isEnabled()); settings->SetDockWidgetPropertiesContentsActive(ui->dockWidgetPropertiesContents->isEnabled()); diff --git a/src/app/tape/tmainwindow.cpp b/src/app/tape/tmainwindow.cpp index 28b06e561..14d2ea115 100644 --- a/src/app/tape/tmainwindow.cpp +++ b/src/app/tape/tmainwindow.cpp @@ -3423,7 +3423,7 @@ void TMainWindow::ReadSettings() { restoreGeometry(settings->GetGeometry()); restoreState(settings->GetWindowState()); - restoreState(settings->GetToolbarsState(), APP_VERSION); + restoreState(settings->GetToolbarsState(), AppVersion()); // Text under tool buton icon ToolBarStyles(); @@ -3443,7 +3443,7 @@ void TMainWindow::WriteSettings() VTapeSettings *settings = MApplication::VApp()->TapeSettings(); settings->SetGeometry(saveGeometry()); settings->SetWindowState(saveState()); - settings->SetToolbarsState(saveState(APP_VERSION)); + settings->SetToolbarsState(saveState(AppVersion())); settings->sync(); if (settings->status() == QSettings::AccessError) diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index c57d987bf..f3fbca7cb 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -4558,7 +4558,7 @@ void MainWindow::ReadSettings() { restoreGeometry(settings->GetGeometry()); restoreState(settings->GetWindowState()); - restoreState(settings->GetToolbarsState(), APP_VERSION); + restoreState(settings->GetToolbarsState(), AppVersion()); ui->dockWidgetGroups->setVisible(settings->IsDockWidgetGroupsActive()); ui->dockWidgetToolOptions->setVisible(settings->IsDockWidgetToolOptionsActive()); @@ -4600,7 +4600,7 @@ void MainWindow::WriteSettings() VValentinaSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings(); settings->SetGeometry(saveGeometry()); settings->SetWindowState(saveState()); - settings->SetToolbarsState(saveState(APP_VERSION)); + settings->SetToolbarsState(saveState(AppVersion())); settings->SetDockWidgetGroupsActive(ui->dockWidgetGroups->isEnabled()); settings->SetDockWidgetToolOptionsActive(ui->dockWidgetToolOptions->isEnabled()); diff --git a/src/libs/fervor/fvupdater.cpp b/src/libs/fervor/fvupdater.cpp index 3921938ce..a0ec1ffa6 100644 --- a/src/libs/fervor/fvupdater.cpp +++ b/src/libs/fervor/fvupdater.cpp @@ -532,7 +532,7 @@ bool FvUpdater::VersionIsIgnored(const QString &version) // 3) A newer version (don't ignore) // 'version' is not likely to contain an older version in any case. - int decVersion = 0x0; + unsigned decVersion = 0x0; try { decVersion = VAbstractConverter::GetFormatVersion(version); @@ -543,12 +543,12 @@ bool FvUpdater::VersionIsIgnored(const QString &version) return true; // Ignore invalid version } - if (decVersion == APP_VERSION) + if (decVersion == AppVersion()) { return true; } - const int lastSkippedVersion = VAbstractApplication::VApp()->Settings()->GetLatestSkippedVersion(); + const unsigned lastSkippedVersion = VAbstractApplication::VApp()->Settings()->GetLatestSkippedVersion(); if (lastSkippedVersion != 0x0) { if (decVersion == lastSkippedVersion) @@ -558,7 +558,7 @@ bool FvUpdater::VersionIsIgnored(const QString &version) } } - if (decVersion > APP_VERSION) + if (decVersion > AppVersion()) { // Newer version - do not skip return false; @@ -571,7 +571,7 @@ bool FvUpdater::VersionIsIgnored(const QString &version) //--------------------------------------------------------------------------------------------------------------------- void FvUpdater::IgnoreVersion(const QString &version) { - int decVersion = 0x0; + unsigned decVersion = 0x0; try { decVersion = VAbstractConverter::GetFormatVersion(version); @@ -582,7 +582,7 @@ void FvUpdater::IgnoreVersion(const QString &version) return ; // Ignore invalid version } - if (decVersion == APP_VERSION) + if (decVersion == AppVersion()) { // Don't ignore the current version return; diff --git a/src/libs/ifc/xml/vabstractconverter.h b/src/libs/ifc/xml/vabstractconverter.h index 804b9ec2f..254b9d6d0 100644 --- a/src/libs/ifc/xml/vabstractconverter.h +++ b/src/libs/ifc/xml/vabstractconverter.h @@ -36,11 +36,7 @@ #include #include "vdomdocument.h" - -constexpr inline auto FormatVersion(unsigned major, unsigned minor, unsigned patch) -> unsigned -{ - return ((major<<16u)|(minor<<8u)|patch); -} +#include "../vmisc/projectversion.h" class VAbstractConverter :public VDomDocument { diff --git a/src/libs/vmisc/customevents.h b/src/libs/vmisc/customevents.h index d99ca8b1a..1b74fe4f3 100644 --- a/src/libs/vmisc/customevents.h +++ b/src/libs/vmisc/customevents.h @@ -43,9 +43,14 @@ enum CustomEventType { }; //--------------------------------------------------------------------------------------------------------------------- +QT_WARNING_PUSH +QT_WARNING_DISABLE_CLANG("-Wenum-enum-conversion") + // Define undo event identifier const QEvent::Type UNDO_EVENT = static_cast(QEvent::User + CustomEventType::UndoEventType); +QT_WARNING_POP + class UndoEvent : public QEvent { public: @@ -57,8 +62,13 @@ public: }; //--------------------------------------------------------------------------------------------------------------------- +QT_WARNING_PUSH +QT_WARNING_DISABLE_CLANG("-Wenum-enum-conversion") + const QEvent::Type LITE_PARSE_EVENT = static_cast(QEvent::User + CustomEventType::LiteParseEventType); +QT_WARNING_POP + class LiteParseEvent : public QEvent { public: @@ -70,9 +80,14 @@ public: }; //--------------------------------------------------------------------------------------------------------------------- +QT_WARNING_PUSH +QT_WARNING_DISABLE_CLANG("-Wenum-enum-conversion") + const QEvent::Type FIT_BEST_CURRENT_EVENT = static_cast(QEvent::User + CustomEventType::FitBestCurrentEventType); +QT_WARNING_POP + class FitBestCurrentEvent : public QEvent { public: @@ -84,9 +99,14 @@ public: }; //--------------------------------------------------------------------------------------------------------------------- +QT_WARNING_PUSH +QT_WARNING_DISABLE_CLANG("-Wenum-enum-conversion") + const QEvent::Type WARNING_MESSAGE_EVENT = static_cast(QEvent::User + CustomEventType::WarningMessageEventType); +QT_WARNING_POP + class WarningMessageEvent : public QEvent { public: diff --git a/src/libs/vmisc/projectversion.cpp b/src/libs/vmisc/projectversion.cpp index 83eae94bf..9efa01602 100644 --- a/src/libs/vmisc/projectversion.cpp +++ b/src/libs/vmisc/projectversion.cpp @@ -40,10 +40,6 @@ #include #include -extern const int MAJOR_VERSION = 0; -extern const int MINOR_VERSION = 7; -extern const int DEBUG_VERSION = 49; - extern const QString APP_VERSION_STR(QStringLiteral("%1.%2.%3.%4").arg(MAJOR_VERSION).arg(MINOR_VERSION) .arg(DEBUG_VERSION).arg(LATEST_TAG_DISTANCE)); diff --git a/src/libs/vmisc/projectversion.h b/src/libs/vmisc/projectversion.h index ec58c3799..60554335e 100644 --- a/src/libs/vmisc/projectversion.h +++ b/src/libs/vmisc/projectversion.h @@ -31,20 +31,21 @@ class QString; -extern const int MAJOR_VERSION; -extern const int MINOR_VERSION; -extern const int DEBUG_VERSION; +constexpr unsigned MAJOR_VERSION = 0; +constexpr unsigned MINOR_VERSION = 7; +constexpr unsigned DEBUG_VERSION = 49; extern const QString APP_VERSION_STR; -/* - APP_VERSION is (major << 16) + (minor << 8) + patch. -*/ -#define APP_VERSION V_VERSION_CHECK(MAJOR_VERSION, MINOR_VERSION, DEBUG_VERSION) -/* - can be used like #if (APP_VERSION >= V_VERSION_CHECK(0, 7, 0)) -*/ -#define V_VERSION_CHECK(major, minor, patch) ((major<<16)|(minor<<8)|(patch)) +constexpr inline auto FormatVersion(unsigned major, unsigned minor, unsigned patch) -> unsigned +{ + return ((major<<16u)|(minor<<8u)|patch); +} + +constexpr inline auto AppVersion() -> unsigned +{ + return FormatVersion(MAJOR_VERSION, MINOR_VERSION, DEBUG_VERSION); +} // Change version number in projectversion.cpp too. // Synchronize valentina.nsi diff --git a/src/libs/vmisc/vcommonsettings.cpp b/src/libs/vmisc/vcommonsettings.cpp index 2609b26d3..3bed1871f 100644 --- a/src/libs/vmisc/vcommonsettings.cpp +++ b/src/libs/vmisc/vcommonsettings.cpp @@ -800,14 +800,14 @@ void VCommonSettings::SetFinalMeasurementsDialogSize(const QSize &sz) } //--------------------------------------------------------------------------------------------------------------------- -int VCommonSettings::GetLatestSkippedVersion() const +unsigned VCommonSettings::GetLatestSkippedVersion() const { QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename); - return settings.value(*settingLatestSkippedVersion, 0x0).toInt(); + return settings.value(*settingLatestSkippedVersion, 0x0).toUInt(); } //--------------------------------------------------------------------------------------------------------------------- -void VCommonSettings::SetLatestSkippedVersion(int value) +void VCommonSettings::SetLatestSkippedVersion(unsigned value) { QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename); settings.setValue(*settingLatestSkippedVersion, value); diff --git a/src/libs/vmisc/vcommonsettings.h b/src/libs/vmisc/vcommonsettings.h index 53293db6b..1d9a5bc75 100644 --- a/src/libs/vmisc/vcommonsettings.h +++ b/src/libs/vmisc/vcommonsettings.h @@ -153,8 +153,8 @@ public: QSize GetFinalMeasurementsDialogSize() const; void SetFinalMeasurementsDialogSize(const QSize& sz); - int GetLatestSkippedVersion() const; - void SetLatestSkippedVersion(int value); + unsigned GetLatestSkippedVersion() const; + void SetLatestSkippedVersion(unsigned value); QDate GetDateOfLastRemind() const; void SetDateOfLastRemind(const QDate &date);