From e3e262e42e97d7aa4c1e0391ce706c0a0cd92dd9 Mon Sep 17 00:00:00 2001 From: Kevin Ottens Date: Thu, 28 May 2020 16:59:24 +0200 Subject: [PATCH] Use default member init when applicable This also fixes a couple of warnings at places (out of order init for instance) and a potential bug in the webflow credentials / qtkeychain integration. Signed-off-by: Kevin Ottens --- .clang-tidy | 4 ++++ .../QProgressIndicator/QProgressIndicator.cpp | 7 +----- .../QProgressIndicator/QProgressIndicator.h | 10 ++++---- src/3rdparty/qtokenizer/qtokenizer.h | 7 +++--- src/common/ownsql.cpp | 2 -- src/common/ownsql.h | 4 ++-- src/common/syncjournalfilerecord.cpp | 4 ---- src/common/syncjournalfilerecord.h | 10 ++++---- src/csync/csync.h | 17 +++++-------- src/gui/creds/shibbolethcredentials.cpp | 5 ---- src/gui/creds/shibbolethcredentials.h | 6 ++--- src/gui/creds/webflowcredentials.cpp | 6 ----- src/gui/creds/webflowcredentials.h | 8 +++---- src/gui/elidedlabel.cpp | 1 - src/gui/elidedlabel.h | 2 +- src/gui/folderman.cpp | 3 --- src/gui/folderman.h | 6 ++--- src/gui/folderstatusmodel.cpp | 2 -- src/gui/folderstatusmodel.h | 4 ++-- src/gui/generalsettings.cpp | 1 - src/gui/generalsettings.h | 2 +- src/gui/proxyauthhandler.cpp | 4 ---- src/gui/proxyauthhandler.h | 8 +++---- src/gui/systray.cpp | 4 +--- src/gui/systray.h | 4 ++-- src/gui/tray/UserModel.cpp | 1 - src/gui/tray/UserModel.h | 2 +- src/gui/wizard/flow2authcredspage.cpp | 3 +-- src/gui/wizard/flow2authcredspage.h | 4 ++-- src/gui/wizard/flow2authwidget.cpp | 3 --- src/gui/wizard/flow2authwidget.h | 4 ++-- src/gui/wizard/owncloudadvancedsetuppage.cpp | 7 ------ src/gui/wizard/owncloudadvancedsetuppage.h | 10 ++++---- src/gui/wizard/owncloudsetuppage.cpp | 8 +------ src/gui/wizard/owncloudsetuppage.h | 11 ++++----- .../wizard/owncloudshibbolethcredspage.cpp | 2 -- src/gui/wizard/owncloudshibbolethcredspage.h | 2 +- src/gui/wizard/owncloudwizard.cpp | 5 +--- src/gui/wizard/owncloudwizard.h | 4 ++-- src/gui/wizard/owncloudwizardresultpage.cpp | 4 ---- src/gui/wizard/owncloudwizardresultpage.h | 2 +- src/libsync/creds/abstractcredentials.cpp | 2 -- src/libsync/creds/abstractcredentials.h | 4 ++-- src/libsync/creds/httpcredentials.cpp | 2 -- src/libsync/creds/httpcredentials.h | 4 ++-- src/libsync/discoveryphase.h | 6 +---- src/libsync/logger.cpp | 5 ---- src/libsync/logger.h | 10 ++++---- src/libsync/progressdispatcher.h | 19 ++++----------- src/libsync/syncfileitem.h | 24 +++++++------------ src/libsync/syncfilestatus.cpp | 2 -- src/libsync/syncfilestatus.h | 4 ++-- src/libsync/syncresult.cpp | 12 ---------- src/libsync/syncresult.h | 22 ++++++++--------- src/libsync/theme.cpp | 1 - src/libsync/theme.h | 2 +- 56 files changed, 105 insertions(+), 217 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 071f522fd..9c41a78db 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -6,6 +6,7 @@ Checks: '-*, modernize-shrink-to-fit, modernize-use-auto, modernize-use-bool-literals, + modernize-use-default-member-init, modernize-use-emplace, modernize-use-noexcept, modernize-use-transparent-functors, @@ -15,3 +16,6 @@ WarningsAsErrors: '*' HeaderFilterRegex: '.*' AnalyzeTemporaryDtors: false FormatStyle: none +CheckOptions: + - key: modernize-use-default-member-init.UseAssignment + value: 1 diff --git a/src/3rdparty/QProgressIndicator/QProgressIndicator.cpp b/src/3rdparty/QProgressIndicator/QProgressIndicator.cpp index 3d536f243..f32eb6e2f 100644 --- a/src/3rdparty/QProgressIndicator/QProgressIndicator.cpp +++ b/src/3rdparty/QProgressIndicator/QProgressIndicator.cpp @@ -27,12 +27,7 @@ #include QProgressIndicator::QProgressIndicator(QWidget* parent) - : QWidget(parent), - m_angle(0), - m_timerId(-1), - m_delay(40), - m_displayedWhenStopped(false), - m_color(Qt::black) + : QWidget(parent) { setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); setFocusPolicy(Qt::NoFocus); diff --git a/src/3rdparty/QProgressIndicator/QProgressIndicator.h b/src/3rdparty/QProgressIndicator/QProgressIndicator.h index a6178080e..727866009 100644 --- a/src/3rdparty/QProgressIndicator/QProgressIndicator.h +++ b/src/3rdparty/QProgressIndicator/QProgressIndicator.h @@ -101,11 +101,11 @@ protected: virtual void timerEvent(QTimerEvent * event); virtual void paintEvent(QPaintEvent * event); private: - int m_angle; - int m_timerId; - int m_delay; - bool m_displayedWhenStopped; - QColor m_color; + int m_angle = 0; + int m_timerId = -1; + int m_delay = 40; + bool m_displayedWhenStopped = false; + QColor m_color = Qt::black; }; #endif // QPROGRESSINDICATOR_H diff --git a/src/3rdparty/qtokenizer/qtokenizer.h b/src/3rdparty/qtokenizer/qtokenizer.h index 2c4b082b4..95f1e3212 100644 --- a/src/3rdparty/qtokenizer/qtokenizer.h +++ b/src/3rdparty/qtokenizer/qtokenizer.h @@ -53,10 +53,9 @@ struct QTokenizerPrivate { typedef typename T::value_type char_type; struct State { - bool inQuote; - bool inEscape; - char_type quoteChar; - State() : inQuote(false), inEscape(false), quoteChar('\0') {} + bool inQuote = false; + bool inEscape = false; + char_type quoteChar = '\0'; }; QTokenizerPrivate(const T& _string, const T& _delims) : diff --git a/src/common/ownsql.cpp b/src/common/ownsql.cpp index f7151321a..5646e0ab4 100644 --- a/src/common/ownsql.cpp +++ b/src/common/ownsql.cpp @@ -44,8 +44,6 @@ namespace OCC { Q_LOGGING_CATEGORY(lcSql, "nextcloud.sync.database.sql", QtInfoMsg) SqlDatabase::SqlDatabase() - : _db(nullptr) - , _errId(0) { } diff --git a/src/common/ownsql.h b/src/common/ownsql.h index 250fa109b..a45734a41 100644 --- a/src/common/ownsql.h +++ b/src/common/ownsql.h @@ -62,9 +62,9 @@ private: bool openHelper(const QString &filename, int sqliteFlags); CheckDbResult checkDb(); - sqlite3 *_db; + sqlite3 *_db = nullptr; QString _error; // last error string - int _errId; + int _errId = 0; friend class SqlQuery; QSet _queries; diff --git a/src/common/syncjournalfilerecord.cpp b/src/common/syncjournalfilerecord.cpp index 607d2e6db..082b52b6d 100644 --- a/src/common/syncjournalfilerecord.cpp +++ b/src/common/syncjournalfilerecord.cpp @@ -22,10 +22,6 @@ namespace OCC { SyncJournalFileRecord::SyncJournalFileRecord() - : _inode(0) - , _type(ItemTypeSkip) - , _fileSize(0) - , _serverHasIgnoredFiles(false) { } diff --git a/src/common/syncjournalfilerecord.h b/src/common/syncjournalfilerecord.h index 0e02f1253..3124f7820 100644 --- a/src/common/syncjournalfilerecord.h +++ b/src/common/syncjournalfilerecord.h @@ -55,14 +55,14 @@ public: QDateTime modDateTime() const { return Utility::qDateTimeFromTime_t(_modtime); } QByteArray _path; - quint64 _inode; - qint64 _modtime; - ItemType _type; + quint64 _inode = 0; + qint64 _modtime = 0; + ItemType _type = ItemTypeSkip; QByteArray _etag; QByteArray _fileId; - qint64 _fileSize; + qint64 _fileSize = 0; RemotePermissions _remotePerm; - bool _serverHasIgnoredFiles; + bool _serverHasIgnoredFiles = false; QByteArray _checksumHeader; QByteArray _e2eMangledName; }; diff --git a/src/csync/csync.h b/src/csync/csync.h index fecf511bf..408693205 100644 --- a/src/csync/csync.h +++ b/src/csync/csync.h @@ -149,9 +149,9 @@ enum ItemType { typedef struct csync_file_stat_s csync_file_stat_t; struct OCSYNC_EXPORT csync_file_stat_s { - time_t modtime; - int64_t size; - uint64_t inode; + time_t modtime = 0; + int64_t size = 0; + uint64_t inode = 0; OCC::RemotePermissions remotePerm; ItemType type BITFIELD(4); @@ -174,20 +174,15 @@ struct OCSYNC_EXPORT csync_file_stat_s { QByteArray checksumHeader; QByteArray e2eMangledName; - CSYNC_STATUS error_status; + CSYNC_STATUS error_status = CSYNC_STATUS_OK; - enum csync_instructions_e instruction; /* u32 */ + enum csync_instructions_e instruction = CSYNC_INSTRUCTION_NONE; /* u32 */ csync_file_stat_s() - : modtime(0) - , size(0) - , inode(0) - , type(ItemTypeSkip) + : type(ItemTypeSkip) , child_modified(false) , has_ignored_files(false) , is_hidden(false) - , error_status(CSYNC_STATUS_OK) - , instruction(CSYNC_INSTRUCTION_NONE) { } static std::unique_ptr fromSyncJournalFileRecord(const OCC::SyncJournalFileRecord &rec); diff --git a/src/gui/creds/shibbolethcredentials.cpp b/src/gui/creds/shibbolethcredentials.cpp index a09136a97..b19133785 100644 --- a/src/gui/creds/shibbolethcredentials.cpp +++ b/src/gui/creds/shibbolethcredentials.cpp @@ -51,11 +51,6 @@ namespace { ShibbolethCredentials::ShibbolethCredentials() : AbstractCredentials() - , _url() - , _ready(false) - , _stillValid(false) - , _browser(nullptr) - , _keychainMigration(false) { } diff --git a/src/gui/creds/shibbolethcredentials.h b/src/gui/creds/shibbolethcredentials.h index a94b398a7..cc9df8506 100644 --- a/src/gui/creds/shibbolethcredentials.h +++ b/src/gui/creds/shibbolethcredentials.h @@ -91,12 +91,12 @@ private: QUrl _url; QByteArray prepareCookieData() const; - bool _ready; - bool _stillValid; + bool _ready = false; + bool _stillValid = false; QPointer _browser; QNetworkCookie _shibCookie; QString _user; - bool _keychainMigration; + bool _keychainMigration = false; }; } // namespace OCC diff --git a/src/gui/creds/webflowcredentials.cpp b/src/gui/creds/webflowcredentials.cpp index 16d4ccd62..ce0d7b41f 100644 --- a/src/gui/creds/webflowcredentials.cpp +++ b/src/gui/creds/webflowcredentials.cpp @@ -87,10 +87,6 @@ static void addSettingsToJob(Account *account, QKeychain::Job *job) #endif WebFlowCredentials::WebFlowCredentials() - : _ready(false) - , _credentialsValid(false) - , _keychainMigration(false) - , _retryOnKeyChainError(false) { } @@ -103,8 +99,6 @@ WebFlowCredentials::WebFlowCredentials(const QString &user, const QString &passw , _clientSslCaCertificates(caCertificates) , _ready(true) , _credentialsValid(true) - , _keychainMigration(false) - , _retryOnKeyChainError(false) { } diff --git a/src/gui/creds/webflowcredentials.h b/src/gui/creds/webflowcredentials.h index 4b2414b01..511ab542e 100644 --- a/src/gui/creds/webflowcredentials.h +++ b/src/gui/creds/webflowcredentials.h @@ -119,12 +119,12 @@ protected: QSslCertificate _clientSslCertificate; QList _clientSslCaCertificates; - bool _ready; - bool _credentialsValid; - bool _keychainMigration; + bool _ready = false; + bool _credentialsValid = false; + bool _keychainMigration = false; bool _retryOnKeyChainError = true; // true if we haven't done yet any reading from keychain - WebFlowCredentialsDialog *_askDialog; + WebFlowCredentialsDialog *_askDialog = nullptr; }; } // namespace OCC diff --git a/src/gui/elidedlabel.cpp b/src/gui/elidedlabel.cpp index f397e7edd..6b3740663 100644 --- a/src/gui/elidedlabel.cpp +++ b/src/gui/elidedlabel.cpp @@ -20,7 +20,6 @@ namespace OCC { ElidedLabel::ElidedLabel(QWidget *parent) : QLabel(parent) - , _elideMode(Qt::ElideNone) { } diff --git a/src/gui/elidedlabel.h b/src/gui/elidedlabel.h index 968628c8f..e101a65da 100644 --- a/src/gui/elidedlabel.h +++ b/src/gui/elidedlabel.h @@ -38,7 +38,7 @@ protected: private: QString _text; - Qt::TextElideMode _elideMode; + Qt::TextElideMode _elideMode = Qt::ElideNone; }; } diff --git a/src/gui/folderman.cpp b/src/gui/folderman.cpp index 71f991c71..3ab24df78 100644 --- a/src/gui/folderman.cpp +++ b/src/gui/folderman.cpp @@ -47,11 +47,8 @@ FolderMan *FolderMan::_instance = nullptr; FolderMan::FolderMan(QObject *parent) : QObject(parent) - , _currentSyncFolder(nullptr) - , _syncEnabled(true) , _lockWatcher(new LockWatcher) , _navigationPaneHelper(this) - , _appRestartRequired(false) { ASSERT(!_instance); _instance = this; diff --git a/src/gui/folderman.h b/src/gui/folderman.h index 97d4b8f45..d4d311bec 100644 --- a/src/gui/folderman.h +++ b/src/gui/folderman.h @@ -304,9 +304,9 @@ private: QSet _disabledFolders; Folder::Map _folderMap; QString _folderConfigPath; - Folder *_currentSyncFolder; + Folder *_currentSyncFolder = nullptr; QPointer _lastSyncFolder; - bool _syncEnabled; + bool _syncEnabled = true; /// Starts regular etag query jobs QTimer _etagPollTimer; @@ -328,7 +328,7 @@ private: QScopedPointer _socketApi; NavigationPaneHelper _navigationPaneHelper; - bool _appRestartRequired; + bool _appRestartRequired = false; static FolderMan *_instance; explicit FolderMan(QObject *parent = nullptr); diff --git a/src/gui/folderstatusmodel.cpp b/src/gui/folderstatusmodel.cpp index 59299a999..35bcd85e1 100644 --- a/src/gui/folderstatusmodel.cpp +++ b/src/gui/folderstatusmodel.cpp @@ -43,8 +43,6 @@ static QString removeTrailingSlash(const QString &s) FolderStatusModel::FolderStatusModel(QObject *parent) : QAbstractItemModel(parent) - , _accountState(nullptr) - , _dirty(false) { } diff --git a/src/gui/folderstatusmodel.h b/src/gui/folderstatusmodel.h index 457e337d1..8c9a56478 100644 --- a/src/gui/folderstatusmodel.h +++ b/src/gui/folderstatusmodel.h @@ -140,8 +140,8 @@ private slots: private: QStringList createBlackList(OCC::FolderStatusModel::SubFolderInfo *root, const QStringList &oldBlackList) const; - const AccountState *_accountState; - bool _dirty; // If the selective sync checkboxes were changed + const AccountState *_accountState = nullptr; + bool _dirty = false; // If the selective sync checkboxes were changed /** * Keeps track of items that are fetching data from the server. diff --git a/src/gui/generalsettings.cpp b/src/gui/generalsettings.cpp index 34672aae7..fff5c9076 100644 --- a/src/gui/generalsettings.cpp +++ b/src/gui/generalsettings.cpp @@ -50,7 +50,6 @@ namespace OCC { GeneralSettings::GeneralSettings(QWidget *parent) : QWidget(parent) , _ui(new Ui::GeneralSettings) - , _currentlyLoading(false) { _ui->setupUi(this); diff --git a/src/gui/generalsettings.h b/src/gui/generalsettings.h index 0c9aa4148..4b5e6a538 100644 --- a/src/gui/generalsettings.h +++ b/src/gui/generalsettings.h @@ -62,7 +62,7 @@ private: Ui::GeneralSettings *_ui; QPointer _ignoreEditor; QPointer _syncLogDialog; - bool _currentlyLoading; + bool _currentlyLoading = false; }; diff --git a/src/gui/proxyauthhandler.cpp b/src/gui/proxyauthhandler.cpp index a75412f13..39310ccf4 100644 --- a/src/gui/proxyauthhandler.cpp +++ b/src/gui/proxyauthhandler.cpp @@ -34,10 +34,6 @@ ProxyAuthHandler *ProxyAuthHandler::instance() } ProxyAuthHandler::ProxyAuthHandler() - : _blocked(false) - , _waitingForDialog(0) - , _waitingForKeychain(0) - , _keychainJobRunning(false) { _dialog = new ProxyAuthDialog(); diff --git a/src/gui/proxyauthhandler.h b/src/gui/proxyauthhandler.h index 3d5afedd3..6e4e24902 100644 --- a/src/gui/proxyauthhandler.h +++ b/src/gui/proxyauthhandler.h @@ -84,14 +84,14 @@ private: /// If the user cancels the credential dialog, blocked will be set to /// true and we won't bother him again. - bool _blocked; + bool _blocked = false; /// In several instances handleProxyAuthenticationRequired() can be called /// while it is still running. These counters detect what we're currently /// waiting for. - int _waitingForDialog; - int _waitingForKeychain; - bool _keychainJobRunning; + int _waitingForDialog = 0; + int _waitingForKeychain = 0; + bool _keychainJobRunning = false; QPointer _dialog; diff --git a/src/gui/systray.cpp b/src/gui/systray.cpp index bd508319b..0c7674d73 100644 --- a/src/gui/systray.cpp +++ b/src/gui/systray.cpp @@ -47,9 +47,7 @@ Systray *Systray::instance() } Systray::Systray() - : _isOpen(false) - , _syncIsPaused(false) - , _trayEngine(new QQmlApplicationEngine(this)) + : _trayEngine(new QQmlApplicationEngine(this)) { _trayEngine->addImportPath("qrc:/qml/theme"); _trayEngine->addImageProvider("avatars", new ImageProvider); diff --git a/src/gui/systray.h b/src/gui/systray.h index 6d55ca36f..0152a75ff 100644 --- a/src/gui/systray.h +++ b/src/gui/systray.h @@ -76,8 +76,8 @@ public slots: private: static Systray *_instance; Systray(); - bool _isOpen; - bool _syncIsPaused; + bool _isOpen = false; + bool _syncIsPaused = false; QQmlApplicationEngine *_trayEngine; }; diff --git a/src/gui/tray/UserModel.cpp b/src/gui/tray/UserModel.cpp index 6938e4c5b..4c3fa4fb5 100644 --- a/src/gui/tray/UserModel.cpp +++ b/src/gui/tray/UserModel.cpp @@ -518,7 +518,6 @@ UserModel *UserModel::instance() UserModel::UserModel(QObject *parent) : QAbstractListModel(parent) - , _currentUserId() { // TODO: Remember selected user from last quit via settings file if (AccountManager::instance()->accounts().size() > 0) { diff --git a/src/gui/tray/UserModel.h b/src/gui/tray/UserModel.h index b52cac0e2..34672dc37 100644 --- a/src/gui/tray/UserModel.h +++ b/src/gui/tray/UserModel.h @@ -134,7 +134,7 @@ private: static UserModel *_instance; UserModel(QObject *parent = 0); QList _users; - int _currentUserId; + int _currentUserId = 0; bool _init = true; void buildUserList(); diff --git a/src/gui/wizard/flow2authcredspage.cpp b/src/gui/wizard/flow2authcredspage.cpp index f0c63f6c8..b9912152d 100644 --- a/src/gui/wizard/flow2authcredspage.cpp +++ b/src/gui/wizard/flow2authcredspage.cpp @@ -29,8 +29,7 @@ namespace OCC { Flow2AuthCredsPage::Flow2AuthCredsPage() - : AbstractCredentialsWizardPage(), - _flow2AuthWidget(nullptr) + : AbstractCredentialsWizardPage() { _layout = new QVBoxLayout(this); diff --git a/src/gui/wizard/flow2authcredspage.h b/src/gui/wizard/flow2authcredspage.h index 8a59605e0..a3afbbcba 100644 --- a/src/gui/wizard/flow2authcredspage.h +++ b/src/gui/wizard/flow2authcredspage.h @@ -61,8 +61,8 @@ public: QString _appPassword; private: - Flow2AuthWidget *_flow2AuthWidget; - QVBoxLayout *_layout; + Flow2AuthWidget *_flow2AuthWidget = nullptr; + QVBoxLayout *_layout = nullptr; }; } // namespace OCC diff --git a/src/gui/wizard/flow2authwidget.cpp b/src/gui/wizard/flow2authwidget.cpp index 498a9803e..7d4524e3a 100644 --- a/src/gui/wizard/flow2authwidget.cpp +++ b/src/gui/wizard/flow2authwidget.cpp @@ -27,10 +27,7 @@ Q_LOGGING_CATEGORY(lcFlow2AuthWidget, "gui.wizard.flow2authwidget", QtInfoMsg) Flow2AuthWidget::Flow2AuthWidget(QWidget *parent) : QWidget(parent) - , _account(nullptr) - , _ui() , _progressIndi(new QProgressIndicator(this)) - , _statusUpdateSkipCount(0) { _ui.setupUi(this); diff --git a/src/gui/wizard/flow2authwidget.h b/src/gui/wizard/flow2authwidget.h index 609791d9b..6c8cb5a2c 100644 --- a/src/gui/wizard/flow2authwidget.h +++ b/src/gui/wizard/flow2authwidget.h @@ -48,7 +48,7 @@ signals: void pollNow(); private: - Account *_account; + Account *_account = nullptr; QScopedPointer _asyncAuth; Ui_Flow2AuthWidget _ui; @@ -62,7 +62,7 @@ private: void customizeStyle(); QProgressIndicator *_progressIndi; - int _statusUpdateSkipCount; + int _statusUpdateSkipCount = 0; }; } // namespace OCC diff --git a/src/gui/wizard/owncloudadvancedsetuppage.cpp b/src/gui/wizard/owncloudadvancedsetuppage.cpp index ce15dc105..4fb0f424a 100644 --- a/src/gui/wizard/owncloudadvancedsetuppage.cpp +++ b/src/gui/wizard/owncloudadvancedsetuppage.cpp @@ -36,14 +36,7 @@ namespace OCC { OwncloudAdvancedSetupPage::OwncloudAdvancedSetupPage() : QWizardPage() - , _ui() - , _checking(false) - , _created(false) - , _localFolderValid(false) , _progressIndi(new QProgressIndicator(this)) - , _remoteFolder() - , _rSize(-1) - , _rSelectedSize(-1) { _ui.setupUi(this); diff --git a/src/gui/wizard/owncloudadvancedsetuppage.h b/src/gui/wizard/owncloudadvancedsetuppage.h index e3d328a18..f49fc8f1d 100644 --- a/src/gui/wizard/owncloudadvancedsetuppage.h +++ b/src/gui/wizard/owncloudadvancedsetuppage.h @@ -71,14 +71,14 @@ private: void customizeStyle(); Ui_OwncloudAdvancedSetupPage _ui; - bool _checking; - bool _created; - bool _localFolderValid; + bool _checking = false; + bool _created = false; + bool _localFolderValid = false; QProgressIndicator *_progressIndi; QString _remoteFolder; QStringList _selectiveSyncBlacklist; - qint64 _rSize; - qint64 _rSelectedSize; + qint64 _rSize = -1; + qint64 _rSelectedSize = -1; }; } // namespace OCC diff --git a/src/gui/wizard/owncloudsetuppage.cpp b/src/gui/wizard/owncloudsetuppage.cpp index d0a41e43c..71f1c19c9 100644 --- a/src/gui/wizard/owncloudsetuppage.cpp +++ b/src/gui/wizard/owncloudsetuppage.cpp @@ -39,16 +39,10 @@ namespace OCC { OwncloudSetupPage::OwncloudSetupPage(QWidget *parent) : QWizardPage() - , _ui() - , _oCUrl() - , _ocUser() - , _authTypeKnown(false) - , _checking(false) - , _authType(DetermineAuthTypeJob::Basic) , _progressIndi(new QProgressIndicator(this)) + , _ocWizard(qobject_cast(parent)) { _ui.setupUi(this); - _ocWizard = qobject_cast(parent); Theme *theme = Theme::instance(); setTitle(WizardCommon::titleTemplate().arg(tr("Connect to %1").arg(theme->appNameGUI()))); diff --git a/src/gui/wizard/owncloudsetuppage.h b/src/gui/wizard/owncloudsetuppage.h index 6e7ed93b0..88d164a72 100644 --- a/src/gui/wizard/owncloudsetuppage.h +++ b/src/gui/wizard/owncloudsetuppage.h @@ -85,16 +85,13 @@ private: QString _oCUrl; QString _ocUser; - bool _authTypeKnown; - bool _checking; - bool _multipleFoldersExist; - DetermineAuthTypeJob::AuthType _authType; + bool _authTypeKnown = false; + bool _checking = false; + DetermineAuthTypeJob::AuthType _authType = DetermineAuthTypeJob::Basic; QProgressIndicator *_progressIndi; - QButtonGroup *_selectiveSyncButtons; - QString _remoteFolder; - AddCertificateDialog *addCertDial; OwncloudWizard *_ocWizard; + AddCertificateDialog *addCertDial = nullptr; }; } // namespace OCC diff --git a/src/gui/wizard/owncloudshibbolethcredspage.cpp b/src/gui/wizard/owncloudshibbolethcredspage.cpp index 3469b42dc..f18d8891d 100644 --- a/src/gui/wizard/owncloudshibbolethcredspage.cpp +++ b/src/gui/wizard/owncloudshibbolethcredspage.cpp @@ -27,8 +27,6 @@ namespace OCC { OwncloudShibbolethCredsPage::OwncloudShibbolethCredsPage() : AbstractCredentialsWizardPage() - , _browser(nullptr) - , _afterInitialSetup(false) { } diff --git a/src/gui/wizard/owncloudshibbolethcredspage.h b/src/gui/wizard/owncloudshibbolethcredspage.h index 32e59d9b0..cf1c48f5b 100644 --- a/src/gui/wizard/owncloudshibbolethcredspage.h +++ b/src/gui/wizard/owncloudshibbolethcredspage.h @@ -58,7 +58,7 @@ private: void setupBrowser(); QPointer _browser; - bool _afterInitialSetup; + bool _afterInitialSetup = false; QNetworkCookie _cookie; }; diff --git a/src/gui/wizard/owncloudwizard.cpp b/src/gui/wizard/owncloudwizard.cpp index 2076136ff..aa7f0aaa4 100644 --- a/src/gui/wizard/owncloudwizard.cpp +++ b/src/gui/wizard/owncloudwizard.cpp @@ -47,16 +47,13 @@ OwncloudWizard::OwncloudWizard(QWidget *parent) , _setupPage(new OwncloudSetupPage(this)) , _httpCredsPage(new OwncloudHttpCredsPage(this)) , _browserCredsPage(new OwncloudOAuthCredsPage) - , _flow2CredsPage(new Flow2AuthCredsPage) #ifndef NO_SHIBBOLETH , _shibbolethCredsPage(new OwncloudShibbolethCredsPage) #endif + , _flow2CredsPage(new Flow2AuthCredsPage) , _advancedSetupPage(new OwncloudAdvancedSetupPage) , _resultPage(new OwncloudWizardResultPage) - , _credentialsPage(nullptr) , _webViewPage(new WebViewPage(this)) - , _setupLog() - , _registration(false) { setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); setPage(WizardCommon::Page_ServerSetup, _setupPage); diff --git a/src/gui/wizard/owncloudwizard.h b/src/gui/wizard/owncloudwizard.h index 3cbf89f71..ee6161ca5 100644 --- a/src/gui/wizard/owncloudwizard.h +++ b/src/gui/wizard/owncloudwizard.h @@ -117,12 +117,12 @@ private: Flow2AuthCredsPage *_flow2CredsPage; OwncloudAdvancedSetupPage *_advancedSetupPage; OwncloudWizardResultPage *_resultPage; - AbstractCredentialsWizardPage *_credentialsPage; + AbstractCredentialsWizardPage *_credentialsPage = nullptr; WebViewPage *_webViewPage; QStringList _setupLog; - bool _registration; + bool _registration = false; friend class OwncloudSetupWizard; }; diff --git a/src/gui/wizard/owncloudwizardresultpage.cpp b/src/gui/wizard/owncloudwizardresultpage.cpp index c7f0ad616..826ef0ade 100644 --- a/src/gui/wizard/owncloudwizardresultpage.cpp +++ b/src/gui/wizard/owncloudwizardresultpage.cpp @@ -25,10 +25,6 @@ namespace OCC { OwncloudWizardResultPage::OwncloudWizardResultPage() : QWizardPage() - , _localFolder() - , _remoteFolder() - , _complete(false) - , _ui() { _ui.setupUi(this); // no fields to register. diff --git a/src/gui/wizard/owncloudwizardresultpage.h b/src/gui/wizard/owncloudwizardresultpage.h index 166b57ab2..416f075e0 100644 --- a/src/gui/wizard/owncloudwizardresultpage.h +++ b/src/gui/wizard/owncloudwizardresultpage.h @@ -50,7 +50,7 @@ protected: private: QString _localFolder; QString _remoteFolder; - bool _complete; + bool _complete = false; Ui_OwncloudWizardResultPage _ui; }; diff --git a/src/libsync/creds/abstractcredentials.cpp b/src/libsync/creds/abstractcredentials.cpp index 677891f84..e71ca059e 100644 --- a/src/libsync/creds/abstractcredentials.cpp +++ b/src/libsync/creds/abstractcredentials.cpp @@ -24,8 +24,6 @@ namespace OCC { Q_LOGGING_CATEGORY(lcCredentials, "nextcloud.sync.credentials", QtInfoMsg) AbstractCredentials::AbstractCredentials() - : _account(nullptr) - , _wasFetched(false) { } diff --git a/src/libsync/creds/abstractcredentials.h b/src/libsync/creds/abstractcredentials.h index 41807c419..896626c12 100644 --- a/src/libsync/creds/abstractcredentials.h +++ b/src/libsync/creds/abstractcredentials.h @@ -103,8 +103,8 @@ Q_SIGNALS: void asked(); protected: - Account *_account; - bool _wasFetched; + Account *_account = nullptr; + bool _wasFetched = false; }; } // namespace OCC diff --git a/src/libsync/creds/httpcredentials.cpp b/src/libsync/creds/httpcredentials.cpp index 31c70a119..d946d7fc7 100644 --- a/src/libsync/creds/httpcredentials.cpp +++ b/src/libsync/creds/httpcredentials.cpp @@ -104,8 +104,6 @@ static void addSettingsToJob(Account *account, QKeychain::Job *job) } HttpCredentials::HttpCredentials() - : _ready(false) - , _keychainMigration(false) { } diff --git a/src/libsync/creds/httpcredentials.h b/src/libsync/creds/httpcredentials.h index 0687f4e5a..1f95084b2 100644 --- a/src/libsync/creds/httpcredentials.h +++ b/src/libsync/creds/httpcredentials.h @@ -137,10 +137,10 @@ protected: QString _previousPassword; QString _fetchErrorString; - bool _ready; + bool _ready = false; QSslKey _clientSslKey; QSslCertificate _clientSslCertificate; - bool _keychainMigration; + bool _keychainMigration = false; bool _retryOnKeyChainError = true; // true if we haven't done yet any reading from keychain }; diff --git a/src/libsync/discoveryphase.h b/src/libsync/discoveryphase.h index 04b2ae097..a5c8521b7 100644 --- a/src/libsync/discoveryphase.h +++ b/src/libsync/discoveryphase.h @@ -40,12 +40,8 @@ struct DiscoveryDirectoryResult { QString path; QString msg; - int code; + int code = EIO; std::deque> list; - DiscoveryDirectoryResult() - : code(EIO) - { - } }; /** diff --git a/src/libsync/logger.cpp b/src/libsync/logger.cpp index c4d294aec..91446553e 100644 --- a/src/libsync/logger.cpp +++ b/src/libsync/logger.cpp @@ -48,11 +48,6 @@ Logger *Logger::instance() Logger::Logger(QObject *parent) : QObject(parent) - , _showTime(true) - , _logWindowActivated(false) - , _doFileFlush(false) - , _logExpire(0) - , _logDebug(false) { qSetMessagePattern("[%{function} \t%{message}"); #ifndef NO_MSG_HANDLER diff --git a/src/libsync/logger.h b/src/libsync/logger.h index 91dbb3202..b5742ed44 100644 --- a/src/libsync/logger.h +++ b/src/libsync/logger.h @@ -97,12 +97,12 @@ private: Logger(QObject *parent = nullptr); ~Logger(); QList _logs; - bool _showTime; - bool _logWindowActivated; + bool _showTime = true; + bool _logWindowActivated = false; QFile _logFile; - bool _doFileFlush; - int _logExpire; - bool _logDebug; + bool _doFileFlush = false; + int _logExpire = 0; + bool _logDebug = false; QScopedPointer _logstream; mutable QMutex _mutex; QString _logDirectory; diff --git a/src/libsync/progressdispatcher.h b/src/libsync/progressdispatcher.h index 66b7ba7cd..fc3c8238d 100644 --- a/src/libsync/progressdispatcher.h +++ b/src/libsync/progressdispatcher.h @@ -127,15 +127,6 @@ public: */ struct OWNCLOUDSYNC_EXPORT Progress { - Progress() - : _progressPerSec(0) - , _prevCompleted(0) - , _initialSmoothing(1.0) - , _completed(0) - , _total(0) - { - } - /** Returns the estimates about progress per second and eta. */ Estimates estimates() const; @@ -155,16 +146,16 @@ public: void setCompleted(quint64 completed); // Updated by update() - double _progressPerSec; - quint64 _prevCompleted; + double _progressPerSec = 0; + quint64 _prevCompleted = 0; // Used to get to a good value faster when // progress measurement stats. See update(). - double _initialSmoothing; + double _initialSmoothing = 1.0; // Set and updated by ProgressInfo - quint64 _completed; - quint64 _total; + quint64 _completed = 0; + quint64 _total = 0; friend class ProgressInfo; }; diff --git a/src/libsync/syncfileitem.h b/src/libsync/syncfileitem.h index e054ab83a..2215dca42 100644 --- a/src/libsync/syncfileitem.h +++ b/src/libsync/syncfileitem.h @@ -101,14 +101,6 @@ public: , _errorMayBeBlacklisted(false) , _status(NoStatus) , _isRestoration(false) - , _httpErrorCode(0) - , _affectedItems(1) - , _instruction(CSYNC_INSTRUCTION_NONE) - , _modtime(0) - , _size(0) - , _inode(0) - , _previousSize(0) - , _previousModtime(0) { } @@ -225,20 +217,20 @@ public: // Variables useful to report to the user Status _status BITFIELD(4); bool _isRestoration BITFIELD(1); // The original operation was forbidden, and this is a restoration - quint16 _httpErrorCode; + quint16 _httpErrorCode = 0; RemotePermissions _remotePerm; QString _errorString; // Contains a string only in case of error QByteArray _responseTimeStamp; - quint32 _affectedItems; // the number of affected items by the operation on this item. + quint32 _affectedItems = 1; // the number of affected items by the operation on this item. // usually this value is 1, but for removes on dirs, it might be much higher. // Variables used by the propagator - csync_instructions_e _instruction; + csync_instructions_e _instruction = CSYNC_INSTRUCTION_NONE; QString _originalFile; // as it is in the csync tree - time_t _modtime; + time_t _modtime = 0; QByteArray _etag; - quint64 _size; - quint64 _inode; + quint64 _size = 0; + quint64 _inode = 0; QByteArray _fileId; // This is the value for the 'new' side, matching with _size and _modtime. @@ -250,8 +242,8 @@ public: QByteArray _checksumHeader; // The size and modtime of the file getting overwritten (on the disk for downloads, on the server for uploads). - quint64 _previousSize; - time_t _previousModtime; + quint64 _previousSize = 0; + time_t _previousModtime = 0; QString _directDownloadUrl; QString _directDownloadCookies; diff --git a/src/libsync/syncfilestatus.cpp b/src/libsync/syncfilestatus.cpp index 8d1a5933f..b4bcfd234 100644 --- a/src/libsync/syncfilestatus.cpp +++ b/src/libsync/syncfilestatus.cpp @@ -16,8 +16,6 @@ namespace OCC { SyncFileStatus::SyncFileStatus() - : _tag(StatusNone) - , _shared(false) { } diff --git a/src/libsync/syncfilestatus.h b/src/libsync/syncfilestatus.h index e4743f7a3..f778c89e8 100644 --- a/src/libsync/syncfilestatus.h +++ b/src/libsync/syncfilestatus.h @@ -50,8 +50,8 @@ public: QString toSocketAPIString() const; private: - SyncFileStatusTag _tag; - bool _shared; + SyncFileStatusTag _tag = StatusNone; + bool _shared = false; }; inline bool operator==(const SyncFileStatus &a, const SyncFileStatus &b) diff --git a/src/libsync/syncresult.cpp b/src/libsync/syncresult.cpp index a3481c74f..e33d7354e 100644 --- a/src/libsync/syncresult.cpp +++ b/src/libsync/syncresult.cpp @@ -18,18 +18,6 @@ namespace OCC { SyncResult::SyncResult() - : _status(Undefined) - , _foundFilesNotSynced(false) - , _folderStructureWasChanged(false) - , _numNewItems(0) - , _numRemovedItems(0) - , _numUpdatedItems(0) - , _numRenamedItems(0) - , _numNewConflictItems(0) - , _numOldConflictItems(0) - , _numErrorItems(0) - , _numLockedItems(0) - { } diff --git a/src/libsync/syncresult.h b/src/libsync/syncresult.h index 1a0c680ca..a3079f8af 100644 --- a/src/libsync/syncresult.h +++ b/src/libsync/syncresult.h @@ -86,7 +86,7 @@ public: void processCompletedItem(const SyncFileItemPtr &item); private: - Status _status; + Status _status = Undefined; SyncFileItemVector _syncItems; QDateTime _syncTime; QString _folder; @@ -94,18 +94,18 @@ private: * when the sync tool support this... */ QStringList _errors; - bool _foundFilesNotSynced; - bool _folderStructureWasChanged; + bool _foundFilesNotSynced = false; + bool _folderStructureWasChanged = false; // count new, removed and updated items - int _numNewItems; - int _numRemovedItems; - int _numUpdatedItems; - int _numRenamedItems; - int _numNewConflictItems; - int _numOldConflictItems; - int _numErrorItems; - int _numLockedItems; + int _numNewItems = 0; + int _numRemovedItems = 0; + int _numUpdatedItems = 0; + int _numRenamedItems = 0; + int _numNewConflictItems = 0; + int _numOldConflictItems = 0; + int _numErrorItems = 0; + int _numLockedItems = 0; SyncFileItemPtr _firstItemNew; SyncFileItemPtr _firstItemDeleted; diff --git a/src/libsync/theme.cpp b/src/libsync/theme.cpp index 645ccff8a..5ad0c4363 100644 --- a/src/libsync/theme.cpp +++ b/src/libsync/theme.cpp @@ -204,7 +204,6 @@ QString Theme::hidpiFileName(const QString &fileName, QPaintDevice *dev) Theme::Theme() : QObject(nullptr) - , _mono(false) { } diff --git a/src/libsync/theme.h b/src/libsync/theme.h index 2d0657648..2ecbf6c81 100644 --- a/src/libsync/theme.h +++ b/src/libsync/theme.h @@ -466,7 +466,7 @@ private: Theme &operator=(Theme const &); static Theme *_instance; - bool _mono; + bool _mono = false; #ifndef TOKEN_AUTH_ONLY mutable QHash _iconCache; #endif -- 2.30.2