From 92b60dac65a5fb5723d3faf456f664aad96df7dc Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 17 Apr 2019 10:57:29 +0200 Subject: [PATCH 1/9] [libcalamares] Warnings-- over extra ; --- src/libcalamares/CppJob.cpp | 2 +- src/libcalamares/utils/Logger.cpp | 4 +--- src/libcalamares/utils/PluginFactory.h | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/libcalamares/CppJob.cpp b/src/libcalamares/CppJob.cpp index b3f2385c6..0512df377 100644 --- a/src/libcalamares/CppJob.cpp +++ b/src/libcalamares/CppJob.cpp @@ -41,7 +41,7 @@ CppJob::setModuleInstanceKey( const QString& instanceKey ) void CppJob::setConfigurationMap( const QVariantMap& configurationMap ) { - Q_UNUSED( configurationMap ); + Q_UNUSED( configurationMap ) } } diff --git a/src/libcalamares/utils/Logger.cpp b/src/libcalamares/utils/Logger.cpp index 5f4401ca1..cbe711698 100644 --- a/src/libcalamares/utils/Logger.cpp +++ b/src/libcalamares/utils/Logger.cpp @@ -99,12 +99,10 @@ log( const char* msg, unsigned int debugLevel ) static void -CalamaresLogHandler( QtMsgType type, const QMessageLogContext& context, const QString& msg ) +CalamaresLogHandler( QtMsgType type, const QMessageLogContext&, const QString& msg ) { static QMutex s_mutex; - Q_UNUSED( context ); - QByteArray ba = msg.toUtf8(); const char* message = ba.constData(); diff --git a/src/libcalamares/utils/PluginFactory.h b/src/libcalamares/utils/PluginFactory.h index 22966b829..7338d53de 100644 --- a/src/libcalamares/utils/PluginFactory.h +++ b/src/libcalamares/utils/PluginFactory.h @@ -269,7 +269,7 @@ protected: template static QObject* createInstance( QWidget* parentWidget, QObject* parent ) { - Q_UNUSED( parentWidget ); + Q_UNUSED( parentWidget ) ParentType* p = nullptr; if ( parent ) { From 27140ff5bb8e3f3798a8f85fbb0843dfee28fc8c Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 18 Apr 2019 11:59:51 +0200 Subject: [PATCH 2/9] [libcalamares] Reduce warnings in KDAB code - This is an older copy of kdsingleapplicationguard, now updated for C++11 warnings; removed __ in header guards, fixed up last of 0-for- nullptr, signedness mismatch. --- .../kdsingleapplicationguard/kdsingleapplicationguard.h | 2 +- src/libcalamares/kdsingleapplicationguard/kdtoolsglobal.cpp | 2 +- src/libcalamares/kdsingleapplicationguard/kdtoolsglobal.h | 2 +- src/libcalamares/kdsingleapplicationguard/pimpl_ptr.h | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/libcalamares/kdsingleapplicationguard/kdsingleapplicationguard.h b/src/libcalamares/kdsingleapplicationguard/kdsingleapplicationguard.h index 3bd1e644d..d529fdb3e 100644 --- a/src/libcalamares/kdsingleapplicationguard/kdsingleapplicationguard.h +++ b/src/libcalamares/kdsingleapplicationguard/kdsingleapplicationguard.h @@ -34,7 +34,7 @@ public: explicit KDSingleApplicationGuard( QObject * parent=nullptr ); explicit KDSingleApplicationGuard( Policy policy, QObject * parent=nullptr ); explicit KDSingleApplicationGuard( const QStringList & arguments, QObject * parent=nullptr ); - explicit KDSingleApplicationGuard( const QStringList & arguments, Policy policy, QObject * parent=0 ); + explicit KDSingleApplicationGuard( const QStringList & arguments, Policy policy, QObject * parent=nullptr ); ~KDSingleApplicationGuard(); bool isOperational() const; diff --git a/src/libcalamares/kdsingleapplicationguard/kdtoolsglobal.cpp b/src/libcalamares/kdsingleapplicationguard/kdtoolsglobal.cpp index 23f19051c..f530cc85b 100644 --- a/src/libcalamares/kdsingleapplicationguard/kdtoolsglobal.cpp +++ b/src/libcalamares/kdsingleapplicationguard/kdtoolsglobal.cpp @@ -27,7 +27,7 @@ static Version kdParseQtVersion( const char * const version ) { return result; } -bool _kdCheckQtVersion_impl( int major, int minor, int patchlevel ) { +bool _kdCheckQtVersion_impl( unsigned int major, unsigned int minor, unsigned int patchlevel ) { static const Version actual = kdParseQtVersion( qVersion() ); // do this only once each run... const Version requested = { { static_cast< unsigned char >( major ), static_cast< unsigned char >( minor ), diff --git a/src/libcalamares/kdsingleapplicationguard/kdtoolsglobal.h b/src/libcalamares/kdsingleapplicationguard/kdtoolsglobal.h index e23b78965..c0e37ac76 100644 --- a/src/libcalamares/kdsingleapplicationguard/kdtoolsglobal.h +++ b/src/libcalamares/kdsingleapplicationguard/kdtoolsglobal.h @@ -78,7 +78,7 @@ inline T & __kdtools__dereference_for_methodcall( T * o ) { #define KDAB_SET_OBJECT_NAME( x ) __kdtools__dereference_for_methodcall( x ).setObjectName( QLatin1String( #x ) ) -KDTOOLSCORE_EXPORT bool _kdCheckQtVersion_impl( int major, int minor=0, int patchlevel=0 ); +KDTOOLSCORE_EXPORT bool _kdCheckQtVersion_impl( unsigned int major, unsigned int minor=0, unsigned int patchlevel=0 ); static inline bool kdCheckQtVersion( unsigned int major, unsigned int minor=0, unsigned int patchlevel=0 ) { return (major<<16|minor<<8|patchlevel) <= static_cast(QT_VERSION) || _kdCheckQtVersion_impl( major, minor, patchlevel ); diff --git a/src/libcalamares/kdsingleapplicationguard/pimpl_ptr.h b/src/libcalamares/kdsingleapplicationguard/pimpl_ptr.h index 6f01cd64c..b66bd11a2 100644 --- a/src/libcalamares/kdsingleapplicationguard/pimpl_ptr.h +++ b/src/libcalamares/kdsingleapplicationguard/pimpl_ptr.h @@ -1,5 +1,5 @@ -#ifndef KDTOOLSCORE__PIMPL_PTR_H -#define KDTOOLSCORE__PIMPL_PTR_H +#ifndef KDTOOLSCORE_PIMPL_PTR_H +#define KDTOOLSCORE_PIMPL_PTR_H #include "kdtoolsglobal.h" @@ -40,5 +40,5 @@ namespace kdtools { } // namespace kdtools #endif -#endif /* KDTOOLSCORE__PIMPL_PTR_H */ +#endif /* KDTOOLSCORE_PIMPL_PTR_H */ From c83395ff6dcedae7ef3eb6bdd853f879aaa412cb Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 17 Apr 2019 11:43:21 +0200 Subject: [PATCH 3/9] Reduce warnings for yaml-cpp - Use only utils/YamlUtils.h to pull in yaml-cpp and supporting code. - When compiling with clang, turn off warnings that the system header for yaml-cpp would generate. --- src/libcalamares/Settings.cpp | 2 -- src/libcalamares/utils/YamlUtils.cpp | 2 -- src/libcalamares/utils/YamlUtils.h | 20 ++++++++++++++----- src/libcalamaresui/Branding.cpp | 3 --- src/libcalamaresui/modulesystem/Module.cpp | 2 -- .../modulesystem/ModuleManager.cpp | 2 -- src/modules/contextualprocess/Tests.cpp | 2 -- src/modules/fsresizer/Tests.cpp | 2 -- src/modules/locale/GeoIPJSON.cpp | 2 -- src/modules/locale/LocaleViewStep.cpp | 2 -- src/modules/netinstall/NetInstallPage.cpp | 2 -- src/modules/netinstall/PackageModel.h | 5 ++++- src/modules/shellprocess/Tests.cpp | 2 -- src/modules/test_conf.cpp | 4 ++-- 14 files changed, 21 insertions(+), 31 deletions(-) diff --git a/src/libcalamares/Settings.cpp b/src/libcalamares/Settings.cpp index 710846a2c..00f17c2b2 100644 --- a/src/libcalamares/Settings.cpp +++ b/src/libcalamares/Settings.cpp @@ -27,8 +27,6 @@ #include #include -#include - static bool hasValue( const YAML::Node& v ) { diff --git a/src/libcalamares/utils/YamlUtils.cpp b/src/libcalamares/utils/YamlUtils.cpp index b9b3425e6..b60978919 100644 --- a/src/libcalamares/utils/YamlUtils.cpp +++ b/src/libcalamares/utils/YamlUtils.cpp @@ -20,8 +20,6 @@ #include "utils/Logger.h" -#include - #include #include #include diff --git a/src/libcalamares/utils/YamlUtils.h b/src/libcalamares/utils/YamlUtils.h index 0fa48e270..68268efdf 100644 --- a/src/libcalamares/utils/YamlUtils.h +++ b/src/libcalamares/utils/YamlUtils.h @@ -26,11 +26,21 @@ class QByteArray; class QFileInfo; -namespace YAML -{ -class Node; -class Exception; -} +// The yaml-cpp headers are not C++11 warning-proof, especially +// with picky compilers like Clang 8. Since we use Clang for the +// find-all-the-warnings case, switch those warnings off for +// the we-can't-change-them system headers. +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant" +#pragma clang diagnostic ignored "-Wshadow" +#endif + +#include + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif /// @brief Appends all te elements of @p node to the string list @p v void operator>>( const YAML::Node& node, QStringList& v ); diff --git a/src/libcalamaresui/Branding.cpp b/src/libcalamaresui/Branding.cpp index e31130520..1838105d7 100644 --- a/src/libcalamaresui/Branding.cpp +++ b/src/libcalamaresui/Branding.cpp @@ -32,9 +32,6 @@ #include #include -#include - - namespace Calamares { diff --git a/src/libcalamaresui/modulesystem/Module.cpp b/src/libcalamaresui/modulesystem/Module.cpp index 73a026fb9..97833edb2 100644 --- a/src/libcalamaresui/modulesystem/Module.cpp +++ b/src/libcalamaresui/modulesystem/Module.cpp @@ -36,8 +36,6 @@ #include "PythonQtViewModule.h" #endif -#include - #include #include #include diff --git a/src/libcalamaresui/modulesystem/ModuleManager.cpp b/src/libcalamaresui/modulesystem/ModuleManager.cpp index b8dbc4ded..d2aa3f5c8 100644 --- a/src/libcalamaresui/modulesystem/ModuleManager.cpp +++ b/src/libcalamaresui/modulesystem/ModuleManager.cpp @@ -28,8 +28,6 @@ #include "utils/Logger.h" #include "utils/YamlUtils.h" -#include - #include #include #include diff --git a/src/modules/contextualprocess/Tests.cpp b/src/modules/contextualprocess/Tests.cpp index 89fb1922c..055e35c53 100644 --- a/src/modules/contextualprocess/Tests.cpp +++ b/src/modules/contextualprocess/Tests.cpp @@ -22,8 +22,6 @@ #include "utils/CommandList.h" #include "utils/YamlUtils.h" -#include - #include #include diff --git a/src/modules/fsresizer/Tests.cpp b/src/modules/fsresizer/Tests.cpp index 0da5d9dab..3c204327a 100644 --- a/src/modules/fsresizer/Tests.cpp +++ b/src/modules/fsresizer/Tests.cpp @@ -25,8 +25,6 @@ #include "utils/Logger.h" #include "utils/YamlUtils.h" -#include - #include #include diff --git a/src/modules/locale/GeoIPJSON.cpp b/src/modules/locale/GeoIPJSON.cpp index b4daf2084..d6a309af7 100644 --- a/src/modules/locale/GeoIPJSON.cpp +++ b/src/modules/locale/GeoIPJSON.cpp @@ -25,8 +25,6 @@ #include -#include - GeoIPJSON::GeoIPJSON(const QString& attribute) : GeoIP( attribute.isEmpty() ? QStringLiteral( "time_zone" ) : attribute ) { diff --git a/src/modules/locale/LocaleViewStep.cpp b/src/modules/locale/LocaleViewStep.cpp index a7dc432f8..b78365dc2 100644 --- a/src/modules/locale/LocaleViewStep.cpp +++ b/src/modules/locale/LocaleViewStep.cpp @@ -42,8 +42,6 @@ #include #include -#include - CALAMARES_PLUGIN_FACTORY_DEFINITION( LocaleViewStepFactory, registerPlugin(); ) diff --git a/src/modules/netinstall/NetInstallPage.cpp b/src/modules/netinstall/NetInstallPage.cpp index 5b7f55be3..607251488 100644 --- a/src/modules/netinstall/NetInstallPage.cpp +++ b/src/modules/netinstall/NetInstallPage.cpp @@ -36,8 +36,6 @@ #include -#include - using CalamaresUtils::yamlToVariant; NetInstallPage::NetInstallPage( QWidget* parent ) diff --git a/src/modules/netinstall/PackageModel.h b/src/modules/netinstall/PackageModel.h index f3ae567ce..f84b2779d 100644 --- a/src/modules/netinstall/PackageModel.h +++ b/src/modules/netinstall/PackageModel.h @@ -27,7 +27,10 @@ #include #include -#include +namespace YAML +{ + class Node; +} class PackageModel : public QAbstractItemModel { diff --git a/src/modules/shellprocess/Tests.cpp b/src/modules/shellprocess/Tests.cpp index 4928e28dd..3672586f0 100644 --- a/src/modules/shellprocess/Tests.cpp +++ b/src/modules/shellprocess/Tests.cpp @@ -26,8 +26,6 @@ #include "utils/Logger.h" #include "utils/YamlUtils.h" -#include - #include #include diff --git a/src/modules/test_conf.cpp b/src/modules/test_conf.cpp index ca6b72cc7..d0746421f 100644 --- a/src/modules/test_conf.cpp +++ b/src/modules/test_conf.cpp @@ -21,13 +21,13 @@ * shipped with each module for correctness -- well, for parseability. */ +#include "utils/YamlUtils.h" + #include #include #include -#include - #include #include From cef2f50510aefa0fd0853c32c957cd4bbda1be6a Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 17 Apr 2019 11:57:46 +0200 Subject: [PATCH 4/9] Reduce warnings about extra ; - Trailing ; after Q_UNUSED - Trailing ; after CALAMARES_RETRANSLATE --- src/calamares/progresstree/ProgressTreeModel.cpp | 6 +++--- src/calamares/progresstree/ViewStepItem.cpp | 2 +- src/libcalamares/PythonJob.cpp | 2 +- src/libcalamaresui/utils/CalamaresUtilsGui.cpp | 2 +- src/libcalamaresui/viewpages/ViewStep.cpp | 2 +- src/libcalamaresui/widgets/FixedAspectRatioLabel.cpp | 2 +- src/modules/finished/FinishedPage.cpp | 2 +- src/modules/finished/FinishedViewStep.cpp | 4 ++-- src/modules/keyboard/KeyboardLayoutModel.cpp | 2 +- src/modules/keyboard/KeyboardPage.cpp | 4 ++-- src/modules/license/LicensePage.cpp | 3 +-- src/modules/locale/LocalePage.cpp | 2 +- src/modules/netinstall/PackageModel.cpp | 2 +- src/modules/partition/gui/ChoicePage.cpp | 4 ++-- src/modules/partition/gui/PartitionLabelsView.cpp | 12 ++++++------ .../partition/gui/PartitionSplitterWidget.cpp | 4 ++-- src/modules/summary/SummaryPage.cpp | 2 +- src/modules/welcome/checker/GeneralRequirements.cpp | 2 +- 18 files changed, 29 insertions(+), 30 deletions(-) diff --git a/src/calamares/progresstree/ProgressTreeModel.cpp b/src/calamares/progresstree/ProgressTreeModel.cpp index cf0a0e44a..e3b4fa030 100644 --- a/src/calamares/progresstree/ProgressTreeModel.cpp +++ b/src/calamares/progresstree/ProgressTreeModel.cpp @@ -98,9 +98,9 @@ ProgressTreeModel::data( const QModelIndex& index, int role ) const QVariant ProgressTreeModel::headerData( int section, Qt::Orientation orientation, int role ) const { - Q_UNUSED( section ); - Q_UNUSED( orientation ); - Q_UNUSED( role ); + Q_UNUSED( section ) + Q_UNUSED( orientation ) + Q_UNUSED( role ) return QVariant(); } diff --git a/src/calamares/progresstree/ViewStepItem.cpp b/src/calamares/progresstree/ViewStepItem.cpp index 50cf0b9f8..7c17ff5ae 100644 --- a/src/calamares/progresstree/ViewStepItem.cpp +++ b/src/calamares/progresstree/ViewStepItem.cpp @@ -46,7 +46,7 @@ void ViewStepItem::appendChild( ProgressTreeItem* item ) { Q_ASSERT( false ); - Q_UNUSED( item ); + Q_UNUSED( item ) } diff --git a/src/libcalamares/PythonJob.cpp b/src/libcalamares/PythonJob.cpp index 65a5c4506..6e8323e49 100644 --- a/src/libcalamares/PythonJob.cpp +++ b/src/libcalamares/PythonJob.cpp @@ -92,7 +92,7 @@ BOOST_PYTHON_MODULE( libcalamares ) bp::object utilsModule( bp::handle<>( bp::borrowed( PyImport_AddModule( "libcalamares.utils" ) ) ) ); bp::scope().attr( "utils" ) = utilsModule; bp::scope utilsScope = utilsModule; - Q_UNUSED( utilsScope ); + Q_UNUSED( utilsScope ) bp::def( "debug", diff --git a/src/libcalamaresui/utils/CalamaresUtilsGui.cpp b/src/libcalamaresui/utils/CalamaresUtilsGui.cpp index 69924f1b8..24b42d4e5 100644 --- a/src/libcalamaresui/utils/CalamaresUtilsGui.cpp +++ b/src/libcalamaresui/utils/CalamaresUtilsGui.cpp @@ -40,7 +40,7 @@ static int s_defaultFontHeight = 0; QPixmap defaultPixmap( ImageType type, ImageMode mode, const QSize& size ) { - Q_UNUSED( mode ); + Q_UNUSED( mode ) QPixmap pixmap; switch ( type ) diff --git a/src/libcalamaresui/viewpages/ViewStep.cpp b/src/libcalamaresui/viewpages/ViewStep.cpp index 8a76a05ce..cdfc7bbc9 100644 --- a/src/libcalamaresui/viewpages/ViewStep.cpp +++ b/src/libcalamaresui/viewpages/ViewStep.cpp @@ -71,7 +71,7 @@ ViewStep::setModuleInstanceKey( const QString& instanceKey ) void ViewStep::setConfigurationMap( const QVariantMap& configurationMap ) { - Q_UNUSED( configurationMap ); + Q_UNUSED( configurationMap ) } diff --git a/src/libcalamaresui/widgets/FixedAspectRatioLabel.cpp b/src/libcalamaresui/widgets/FixedAspectRatioLabel.cpp index 140090b97..d1094bb7c 100644 --- a/src/libcalamaresui/widgets/FixedAspectRatioLabel.cpp +++ b/src/libcalamaresui/widgets/FixedAspectRatioLabel.cpp @@ -43,7 +43,7 @@ FixedAspectRatioLabel::setPixmap( const QPixmap& pixmap ) void FixedAspectRatioLabel::resizeEvent( QResizeEvent* event ) { - Q_UNUSED( event ); + Q_UNUSED( event ) QLabel::setPixmap( m_pixmap.scaled( contentsRect().size(), Qt::KeepAspectRatio, diff --git a/src/modules/finished/FinishedPage.cpp b/src/modules/finished/FinishedPage.cpp index cad05bda4..1bc935d0d 100644 --- a/src/modules/finished/FinishedPage.cpp +++ b/src/modules/finished/FinishedPage.cpp @@ -125,7 +125,7 @@ FinishedPage::focusInEvent( QFocusEvent* e ) void FinishedPage::onInstallationFailed( const QString& message, const QString& details ) { - Q_UNUSED( details ); + Q_UNUSED( details ) if ( Calamares::Settings::instance()->isSetupMode() ) ui->mainText->setText( tr( "

Setup Failed


" "%1 has not been set up on your computer.
" diff --git a/src/modules/finished/FinishedViewStep.cpp b/src/modules/finished/FinishedViewStep.cpp index 721df9765..d01a99ce9 100644 --- a/src/modules/finished/FinishedViewStep.cpp +++ b/src/modules/finished/FinishedViewStep.cpp @@ -148,8 +148,8 @@ FinishedViewStep::jobs() const void FinishedViewStep::onInstallationFailed( const QString& message, const QString& details ) { - Q_UNUSED( message ); - Q_UNUSED( details ); + Q_UNUSED( message ) + Q_UNUSED( details ) installFailed = true; } diff --git a/src/modules/keyboard/KeyboardLayoutModel.cpp b/src/modules/keyboard/KeyboardLayoutModel.cpp index 5b5d37130..0abd89ae2 100644 --- a/src/modules/keyboard/KeyboardLayoutModel.cpp +++ b/src/modules/keyboard/KeyboardLayoutModel.cpp @@ -32,7 +32,7 @@ KeyboardLayoutModel::KeyboardLayoutModel( QObject* parent ) int KeyboardLayoutModel::rowCount( const QModelIndex& parent ) const { - Q_UNUSED( parent ); + Q_UNUSED( parent ) return m_layouts.count(); } diff --git a/src/modules/keyboard/KeyboardPage.cpp b/src/modules/keyboard/KeyboardPage.cpp index 5a82e2545..241d4553e 100644 --- a/src/modules/keyboard/KeyboardPage.cpp +++ b/src/modules/keyboard/KeyboardPage.cpp @@ -436,7 +436,7 @@ void KeyboardPage::onListLayoutCurrentItemChanged( const QModelIndex& current, const QModelIndex& previous ) { - Q_UNUSED( previous ); + Q_UNUSED( previous ) if ( !current.isValid() ) return; @@ -457,7 +457,7 @@ static inline QStringList xkbmap_args( QStringList&& r, const QString& layout, c void KeyboardPage::onListVariantCurrentItemChanged( QListWidgetItem* current, QListWidgetItem* previous ) { - Q_UNUSED( previous ); + Q_UNUSED( previous ) QPersistentModelIndex layoutIndex = ui->listLayout->currentIndex(); LayoutItem* variantItem = dynamic_cast< LayoutItem* >( current ); diff --git a/src/modules/license/LicensePage.cpp b/src/modules/license/LicensePage.cpp index 351c55d79..1fb3de7a8 100644 --- a/src/modules/license/LicensePage.cpp +++ b/src/modules/license/LicensePage.cpp @@ -87,8 +87,7 @@ LicensePage::LicensePage(QWidget *parent) CALAMARES_RETRANSLATE( ui->acceptCheckBox->setText( tr( "I accept the terms and conditions above." ) ); - ); - + ) } diff --git a/src/modules/locale/LocalePage.cpp b/src/modules/locale/LocalePage.cpp index 1ddb2cc0a..c1309a129 100644 --- a/src/modules/locale/LocalePage.cpp +++ b/src/modules/locale/LocalePage.cpp @@ -101,7 +101,7 @@ LocalePage::LocalePage( QWidget* parent ) static_cast< void ( QComboBox::* )( int ) >( &QComboBox::currentIndexChanged ), [this]( int currentIndex ) { - Q_UNUSED( currentIndex ); + Q_UNUSED( currentIndex ) QHash< QString, QList< LocaleGlobal::Location > > regions = LocaleGlobal::getLocations(); if ( !regions.contains( m_regionCombo->currentData().toString() ) ) return; diff --git a/src/modules/netinstall/PackageModel.cpp b/src/modules/netinstall/PackageModel.cpp index f64bd778f..588646816 100644 --- a/src/modules/netinstall/PackageModel.cpp +++ b/src/modules/netinstall/PackageModel.cpp @@ -127,7 +127,7 @@ bool PackageModel::setHeaderData( int section, Qt::Orientation orientation, const QVariant& value, int role ) { - Q_UNUSED( role ); + Q_UNUSED( role ) if ( orientation == Qt::Horizontal ) { diff --git a/src/modules/partition/gui/ChoicePage.cpp b/src/modules/partition/gui/ChoicePage.cpp index fc57d1fad..801f3491e 100644 --- a/src/modules/partition/gui/ChoicePage.cpp +++ b/src/modules/partition/gui/ChoicePage.cpp @@ -540,7 +540,7 @@ void ChoicePage::doAlongsideSetupSplitter( const QModelIndex& current, const QModelIndex& previous ) { - Q_UNUSED( previous ); + Q_UNUSED( previous ) if ( !current.isValid() ) return; @@ -718,7 +718,7 @@ void ChoicePage::onPartitionToReplaceSelected( const QModelIndex& current, const QModelIndex& previous ) { - Q_UNUSED( previous ); + Q_UNUSED( previous ) if ( !current.isValid() ) return; diff --git a/src/modules/partition/gui/PartitionLabelsView.cpp b/src/modules/partition/gui/PartitionLabelsView.cpp index 36774cd20..0da7beba8 100644 --- a/src/modules/partition/gui/PartitionLabelsView.cpp +++ b/src/modules/partition/gui/PartitionLabelsView.cpp @@ -100,7 +100,7 @@ PartitionLabelsView::sizeHint() const void PartitionLabelsView::paintEvent( QPaintEvent* event ) { - Q_UNUSED( event ); + Q_UNUSED( event ) QPainter painter( viewport() ); painter.fillRect( rect(), palette().window() ); @@ -478,7 +478,7 @@ PartitionLabelsView::visualRect( const QModelIndex& idx ) const QRegion PartitionLabelsView::visualRegionForSelection( const QItemSelection& selection ) const { - Q_UNUSED( selection ); + Q_UNUSED( selection ) return QRegion(); } @@ -543,8 +543,8 @@ PartitionLabelsView::setExtendedPartitionHidden( bool hidden ) QModelIndex PartitionLabelsView::moveCursor( CursorAction cursorAction, Qt::KeyboardModifiers modifiers ) { - Q_UNUSED( cursorAction ); - Q_UNUSED( modifiers ); + Q_UNUSED( cursorAction ) + Q_UNUSED( modifiers ) return QModelIndex(); } @@ -553,7 +553,7 @@ PartitionLabelsView::moveCursor( CursorAction cursorAction, Qt::KeyboardModifier bool PartitionLabelsView::isIndexHidden( const QModelIndex& index ) const { - Q_UNUSED( index ); + Q_UNUSED( index ) return false; } @@ -598,7 +598,7 @@ PartitionLabelsView::mouseMoveEvent( QMouseEvent* event ) void PartitionLabelsView::leaveEvent( QEvent* event ) { - Q_UNUSED( event ); + Q_UNUSED( event ) QGuiApplication::restoreOverrideCursor(); if ( m_hoveredIndex.isValid() ) diff --git a/src/modules/partition/gui/PartitionSplitterWidget.cpp b/src/modules/partition/gui/PartitionSplitterWidget.cpp index ae73ecfcd..0281ab32c 100644 --- a/src/modules/partition/gui/PartitionSplitterWidget.cpp +++ b/src/modules/partition/gui/PartitionSplitterWidget.cpp @@ -286,7 +286,7 @@ PartitionSplitterWidget::minimumSizeHint() const void PartitionSplitterWidget::paintEvent( QPaintEvent* event ) { - Q_UNUSED( event ); + Q_UNUSED( event ) QPainter painter( this ); painter.fillRect( rect(), palette().window() ); @@ -401,7 +401,7 @@ PartitionSplitterWidget::mouseMoveEvent( QMouseEvent* event ) void PartitionSplitterWidget::mouseReleaseEvent( QMouseEvent* event ) { - Q_UNUSED( event ); + Q_UNUSED( event ) m_resizing = false; } diff --git a/src/modules/summary/SummaryPage.cpp b/src/modules/summary/SummaryPage.cpp index bddfe9dcc..6913d3e17 100644 --- a/src/modules/summary/SummaryPage.cpp +++ b/src/modules/summary/SummaryPage.cpp @@ -41,7 +41,7 @@ SummaryPage::SummaryPage( const SummaryViewStep* thisViewStep, QWidget* parent ) , m_contentWidget( nullptr ) , m_scrollArea( new QScrollArea( this ) ) { - Q_UNUSED( parent ); + Q_UNUSED( parent ) Q_ASSERT( m_thisViewStep ); QVBoxLayout* layout = new QVBoxLayout( this ); layout->setContentsMargins( 0, 0, 0, 0 ); diff --git a/src/modules/welcome/checker/GeneralRequirements.cpp b/src/modules/welcome/checker/GeneralRequirements.cpp index 067105b28..675d43ed4 100644 --- a/src/modules/welcome/checker/GeneralRequirements.cpp +++ b/src/modules/welcome/checker/GeneralRequirements.cpp @@ -278,7 +278,7 @@ bool GeneralRequirements::checkEnoughStorage( qint64 requiredSpace ) { #ifdef WITHOUT_LIBPARTED - Q_UNUSED( requiredSpace ); + Q_UNUSED( requiredSpace ) cWarning() << "GeneralRequirements is configured without libparted."; return false; #else From bdb7bf71a8ed1cef055cdc50a648ce7cd3e33db8 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 17 Apr 2019 12:19:12 +0200 Subject: [PATCH 5/9] Reduce warnings from moc-generated code - The auto-generated code produces a lot of warnings from Clang 8; this obscures the more meaningful warnings from actual Calamares code, so tone the warnings down. - For Clang, set CALAMARES_MOC_OPTIONS. - Add convenience CMake function for automoccing. It applies the options as needed to a given target. --- CMakeLists.txt | 3 +++ CMakeModules/CalamaresAddLibrary.cmake | 7 +++-- CMakeModules/CalamaresAutomoc.cmake | 36 ++++++++++++++++++++++++++ src/libcalamares/CMakeLists.txt | 4 +-- src/libcalamares/utils/moc-warnings.h | 4 +++ 5 files changed, 48 insertions(+), 6 deletions(-) create mode 100644 CMakeModules/CalamaresAutomoc.cmake create mode 100644 src/libcalamares/utils/moc-warnings.h diff --git a/CMakeLists.txt b/CMakeLists.txt index c9dddb547..ce627fc9b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -208,6 +208,8 @@ if( CMAKE_CXX_COMPILER_ID MATCHES "Clang" ) set( CMAKE_TOOLCHAIN_PREFIX "llvm-" ) set( CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined" ) + + set( CALAMARES_AUTOMOC_OPTIONS "-butils/moc-warnings.h" ) else() set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--no-undefined" ) set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--fatal-warnings -Wnon-virtual-dtor -Woverloaded-virtual -Werror=return-type" ) @@ -509,6 +511,7 @@ install( "CMakeModules/CalamaresAddLibrary.cmake" "CMakeModules/CalamaresAddBrandingSubdirectory.cmake" "CMakeModules/CalamaresAddTranslations.cmake" + "CMakeModules/CalamaresAutomoc.cmake" "CMakeModules/CMakeColors.cmake" DESTINATION "${CMAKE_INSTALL_CMAKEDIR}" diff --git a/CMakeModules/CalamaresAddLibrary.cmake b/CMakeModules/CalamaresAddLibrary.cmake index d5d734989..e731e2b15 100644 --- a/CMakeModules/CalamaresAddLibrary.cmake +++ b/CMakeModules/CalamaresAddLibrary.cmake @@ -44,6 +44,7 @@ # flag (i.e. `-D`) so only state the name (optionally, also the value) # without a `-D` prefixed to it. Pass in a CMake list as needed. include( CMakeParseArguments ) +include( CalamaresAutomoc ) function(calamares_add_library) # parse arguments (name needs to be saved before passing ARGN into the macro) @@ -81,10 +82,8 @@ function(calamares_add_library) add_library(${target} SHARED ${LIBRARY_SOURCES}) endif() - # definitions - can this be moved into set_target_properties below? - add_definitions(${QT_DEFINITIONS}) - set_target_properties(${target} PROPERTIES AUTOMOC TRUE) - + calamares_automoc(${target}) + if(LIBRARY_EXPORT_MACRO) set_target_properties(${target} PROPERTIES COMPILE_DEFINITIONS ${LIBRARY_EXPORT_MACRO}) endif() diff --git a/CMakeModules/CalamaresAutomoc.cmake b/CMakeModules/CalamaresAutomoc.cmake new file mode 100644 index 000000000..0ca5cd89a --- /dev/null +++ b/CMakeModules/CalamaresAutomoc.cmake @@ -0,0 +1,36 @@ +# === This file is part of Calamares - === +# +# Calamares is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Calamares is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Calamares. If not, see . +# +# SPDX-License-Identifier: GPL-3.0+ +# License-Filename: LICENSE +# +### +# +# Helper function for doing automoc on a target. +# +# Sets AUTOMOC TRUE for a target. +# +# If the global variable CALAMARES_AUTOMOC_OPTIONS is set, uses that +# as well to set options passed to MOC. This can be used to add +# libcalamares/utils/moc-warnings.h file to the moc, which in turn +# reduces compiler warnings in generated MOC code. +# + +function(calamares_automoc TARGET) + set_target_properties( ${TARGET} PROPERTIES AUTOMOC TRUE ) + if ( CALAMARES_AUTOMOC_OPTIONS ) + set_target_properties( ${TARGET} PROPERTIES AUTOMOC_MOC_OPTIONS "${CALAMARES_AUTOMOC_OPTIONS}" ) + endif() +endfunction() diff --git a/src/libcalamares/CMakeLists.txt b/src/libcalamares/CMakeLists.txt index a7dd1c0fe..340f8fe3b 100644 --- a/src/libcalamares/CMakeLists.txt +++ b/src/libcalamares/CMakeLists.txt @@ -84,10 +84,10 @@ endif() add_library( calamares SHARED ${libSources} ${kdsagSources} ${utilsSources} ) set_target_properties( calamares PROPERTIES - AUTOMOC TRUE VERSION ${CALAMARES_VERSION_SHORT} SOVERSION ${CALAMARES_VERSION_SHORT} ) +calamares_automoc( calamares ) target_link_libraries( calamares LINK_PRIVATE @@ -114,7 +114,7 @@ if ( ECM_FOUND AND BUILD_TESTING ) Qt5::Core Qt5::Test ) - set_target_properties( libcalamarestest PROPERTIES AUTOMOC TRUE ) + calamares_automoc( libcalamarestest ) endif() # Make symlink lib/calamares/libcalamares.so to lib/libcalamares.so.VERSION so diff --git a/src/libcalamares/utils/moc-warnings.h b/src/libcalamares/utils/moc-warnings.h new file mode 100644 index 000000000..b773c176b --- /dev/null +++ b/src/libcalamares/utils/moc-warnings.h @@ -0,0 +1,4 @@ +#ifdef __clang__ +#pragma clang diagnostic ignored "-Wextra-semi-stmt" +#pragma clang diagnostic ignored "-Wredundant-parens" +#endif From 123c774a478b906a17f6ed9bfbfe42ed503c0494 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 18 Apr 2019 12:01:41 +0200 Subject: [PATCH 6/9] Use new automoc options --- src/calamares/CMakeLists.txt | 2 +- src/modules/contextualprocess/CMakeLists.txt | 2 +- src/modules/locale/CMakeLists.txt | 5 +++-- src/modules/shellprocess/CMakeLists.txt | 2 +- src/modules/users/CMakeLists.txt | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/calamares/CMakeLists.txt b/src/calamares/CMakeLists.txt index e1f8e4236..c913c0959 100644 --- a/src/calamares/CMakeLists.txt +++ b/src/calamares/CMakeLists.txt @@ -38,10 +38,10 @@ set( final_src ${calamaresSources} ${calamaresRc} ${trans_outfile} ) add_executable( calamares_bin ${final_src} ) set_target_properties(calamares_bin PROPERTIES - AUTOMOC TRUE ENABLE_EXPORTS TRUE RUNTIME_OUTPUT_NAME calamares ) +calamares_automoc( calamares_bin ) if( WITH_KF5Crash ) set( LINK_LIBRARIES diff --git a/src/modules/contextualprocess/CMakeLists.txt b/src/modules/contextualprocess/CMakeLists.txt index f75946b58..a7e9ed05b 100644 --- a/src/modules/contextualprocess/CMakeLists.txt +++ b/src/modules/contextualprocess/CMakeLists.txt @@ -21,5 +21,5 @@ if( ECM_FOUND AND BUILD_TESTING ) Qt5::Core Qt5::Test ) - set_target_properties( contextualprocesstest PROPERTIES AUTOMOC TRUE ) + calamares_automoc( contextualprocesstest ) endif() diff --git a/src/modules/locale/CMakeLists.txt b/src/modules/locale/CMakeLists.txt index 8faf8468c..affaa3753 100644 --- a/src/modules/locale/CMakeLists.txt +++ b/src/modules/locale/CMakeLists.txt @@ -54,7 +54,7 @@ if( ECM_FOUND AND BUILD_TESTING ) ${geoip_libs} ${YAMLCPP_LIBRARY} ) - set_target_properties( geoiptest PROPERTIES AUTOMOC TRUE ) + calamares_automoc( geoiptest ) ecm_add_test( Tests.cpp @@ -65,10 +65,11 @@ if( ECM_FOUND AND BUILD_TESTING ) calamares Qt5::Test ) - set_target_properties( localetest PROPERTIES AUTOMOC TRUE ) + calamares_automoc( localetest ) endif() if( BUILD_TESTING ) add_executable( test_geoip test_geoip.cpp ${geoip_src} ) target_link_libraries( test_geoip calamaresui Qt5::Network ${geoip_libs} ${YAMLCPP_LIBRARY} ) + calamares_automoc( test_geoip ) endif() diff --git a/src/modules/shellprocess/CMakeLists.txt b/src/modules/shellprocess/CMakeLists.txt index 82ae8b911..166dff17d 100644 --- a/src/modules/shellprocess/CMakeLists.txt +++ b/src/modules/shellprocess/CMakeLists.txt @@ -20,5 +20,5 @@ if( ECM_FOUND AND BUILD_TESTING ) Qt5::Core Qt5::Test ) - set_target_properties( shellprocesstest PROPERTIES AUTOMOC TRUE ) + calamares_automoc( shellprocesstest ) endif() diff --git a/src/modules/users/CMakeLists.txt b/src/modules/users/CMakeLists.txt index 207ffbb3a..d0e7b6d9d 100644 --- a/src/modules/users/CMakeLists.txt +++ b/src/modules/users/CMakeLists.txt @@ -51,5 +51,5 @@ if( ECM_FOUND AND BUILD_TESTING ) Qt5::Test ${CRYPT_LIBRARIES} ) - set_target_properties( passwordtest PROPERTIES AUTOMOC TRUE ) + calamares_automoc( passwordtest ) endif() From a1e08d2236d5e91d5f4d91c1be294e51258c8848 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 18 Apr 2019 11:40:47 +0200 Subject: [PATCH 7/9] [keyboard] Don't use useless rvalue-ref - Weird && usage here made redundant through RVO, just return something normally instead. --- src/modules/keyboard/KeyboardPage.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/modules/keyboard/KeyboardPage.cpp b/src/modules/keyboard/KeyboardPage.cpp index 241d4553e..3a0da2866 100644 --- a/src/modules/keyboard/KeyboardPage.cpp +++ b/src/modules/keyboard/KeyboardPage.cpp @@ -446,9 +446,9 @@ KeyboardPage::onListLayoutCurrentItemChanged( const QModelIndex& current, /* Returns stringlist with suitable setxkbmap command-line arguments * to set the given @p layout and @p variant. */ -static inline QStringList xkbmap_args( QStringList&& r, const QString& layout, const QString& variant ) +static inline QStringList xkbmap_args( const QString& layout, const QString& variant ) { - r << "-layout" << layout; + QStringList r{ "-layout", layout }; if ( !variant.isEmpty() ) r << "-variant" << variant; return r; @@ -483,7 +483,7 @@ KeyboardPage::onListVariantCurrentItemChanged( QListWidgetItem* current, QListWi connect( &m_setxkbmapTimer, &QTimer::timeout, this, [=] { - QProcess::execute( "setxkbmap", xkbmap_args( QStringList(), layout, variant ) ); + QProcess::execute( "setxkbmap", xkbmap_args( layout, variant ) ); cDebug() << "xkbmap selection changed to: " << layout << '-' << variant; m_setxkbmapTimer.disconnect( this ); } ); From 3ccbcdc1bd7522847d1c1fc7ee5d058af1f02968 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 18 Apr 2019 12:16:27 +0200 Subject: [PATCH 8/9] [libcalamares] Don't moc on JobQueue - There is no reason for JobThread to have a Q_OBJECT macro, so drop the moccing (this also stops some warnings from the generated moc code). - Define the (virtual) destructor out-of-line to avoid vtable warnings. --- src/libcalamares/JobQueue.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/libcalamares/JobQueue.cpp b/src/libcalamares/JobQueue.cpp index 46d58d429..6ef055ffc 100644 --- a/src/libcalamares/JobQueue.cpp +++ b/src/libcalamares/JobQueue.cpp @@ -35,7 +35,6 @@ namespace Calamares class JobThread : public QThread { - Q_OBJECT public: JobThread( JobQueue* queue ) : QThread( queue ) @@ -44,6 +43,8 @@ public: { } + virtual ~JobThread() override; + void setJobs( const JobList& jobs ) { m_jobs = jobs; @@ -122,6 +123,10 @@ private: } }; +JobThread::~JobThread() +{ +} + JobQueue* JobQueue::s_instance = nullptr; @@ -184,5 +189,3 @@ JobQueue::enqueue( const JobList& jobs ) } } // namespace Calamares - -#include "JobQueue.moc" From 3e88b408fa419085a8c23dbf26604f214ef77ad0 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 18 Apr 2019 12:40:04 +0200 Subject: [PATCH 9/9] [calamares] Remove unused item Role --- src/calamares/progresstree/ProgressTreeItem.cpp | 4 +--- src/calamares/progresstree/ProgressTreeModel.h | 1 - src/calamares/progresstree/ViewStepItem.cpp | 2 -- 3 files changed, 1 insertion(+), 6 deletions(-) diff --git a/src/calamares/progresstree/ProgressTreeItem.cpp b/src/calamares/progresstree/ProgressTreeItem.cpp index 769ffaf90..0445962ab 100644 --- a/src/calamares/progresstree/ProgressTreeItem.cpp +++ b/src/calamares/progresstree/ProgressTreeItem.cpp @@ -84,9 +84,7 @@ ProgressTreeRoot::ProgressTreeRoot() QVariant -ProgressTreeRoot::data( int role ) const +ProgressTreeRoot::data( int ) const { - if ( role == ProgressTreeModel::ProgressTreeItemRole ) - return this; return QVariant(); } diff --git a/src/calamares/progresstree/ProgressTreeModel.h b/src/calamares/progresstree/ProgressTreeModel.h index d89707183..0e9574516 100644 --- a/src/calamares/progresstree/ProgressTreeModel.h +++ b/src/calamares/progresstree/ProgressTreeModel.h @@ -35,7 +35,6 @@ class ProgressTreeModel : public QAbstractItemModel public: enum Role { - ProgressTreeItemRole = Qt::UserRole + 10, ProgressTreeItemCurrentRole = Qt::UserRole + 11 }; diff --git a/src/calamares/progresstree/ViewStepItem.cpp b/src/calamares/progresstree/ViewStepItem.cpp index 7c17ff5ae..fe2fe6034 100644 --- a/src/calamares/progresstree/ViewStepItem.cpp +++ b/src/calamares/progresstree/ViewStepItem.cpp @@ -53,8 +53,6 @@ ViewStepItem::appendChild( ProgressTreeItem* item ) QVariant ViewStepItem::data( int role ) const { - if ( role == ProgressTreeModel::ProgressTreeItemRole ) - return this; if ( role == Qt::DisplayRole ) { return m_step ? m_step->prettyName()