diff --git a/samples/cliclient/main.cpp b/samples/cliclient/main.cpp index 321d3ddab..5d108f1e7 100644 --- a/samples/cliclient/main.cpp +++ b/samples/cliclient/main.cpp @@ -27,9 +27,9 @@ int main(int argc, char *argv[]) Client client(&app); LineReader reader; - QObject::connect(&reader, SIGNAL(command(const QString&)), &client, SLOT(command(const QString&))); - QObject::connect(&client, SIGNAL(quit()), &reader, SLOT(terminate())); - QObject::connect(&client, SIGNAL(quit()), &app, SLOT(quit())); + QObject::connect(&reader, &LineReader::command, &client, &Client::command); + QObject::connect(&client, &Client::quit, &reader, &LineReader::terminate); + QObject::connect(&client, &Client::quit, &app, &QCoreApplication::quit); reader.start(); app.exec(); diff --git a/src/blackcore/application.cpp b/src/blackcore/application.cpp index 27884d526..069a8cf4c 100644 --- a/src/blackcore/application.cpp +++ b/src/blackcore/application.cpp @@ -1022,9 +1022,9 @@ namespace BlackCore { if (msgs.isEmpty()) { return; } if (!msgs.hasErrorMessages()) { return; } - return CApplication::cmdLineErrorMessage( - msgs.toFormattedQString(true) - ); + CApplication::cmdLineErrorMessage( + msgs.toFormattedQString(true) + ); } void CApplication::cmdLineHelpMessage() diff --git a/src/blackcore/application.h b/src/blackcore/application.h index bffd82eeb..ffe6ad2f3 100644 --- a/src/blackcore/application.h +++ b/src/blackcore/application.h @@ -389,6 +389,7 @@ namespace BlackCore //! Startup has been completed //! \remark needs to be triggered by application when it think it is done + //! \fixme http://doc.qt.io/qt-5/signalsandslots.html#signals recommends signals be only emitted by their own class void startUpCompleted(bool success); //! Facade started diff --git a/src/blackcore/context/contextaudioproxy.cpp b/src/blackcore/context/contextaudioproxy.cpp index 17bc3293a..224614fcf 100644 --- a/src/blackcore/context/contextaudioproxy.cpp +++ b/src/blackcore/context/contextaudioproxy.cpp @@ -144,7 +144,7 @@ namespace BlackCore void CContextAudioProxy::setMute(bool muted) { - return this->m_dBusInterface->callDBus(QLatin1String("setMute"), muted); + this->m_dBusInterface->callDBus(QLatin1String("setMute"), muted); } bool CContextAudioProxy::isMuted() const diff --git a/src/blackcore/vatsim/networkvatlib.cpp b/src/blackcore/vatsim/networkvatlib.cpp index bc82099b0..83d80bf70 100644 --- a/src/blackcore/vatsim/networkvatlib.cpp +++ b/src/blackcore/vatsim/networkvatlib.cpp @@ -292,6 +292,7 @@ namespace BlackCore std::function CNetworkVatlib::toFSD(const QStringList &qstrList) const { QVector bytesVec; + bytesVec.reserve(qstrList.size()); for (auto i = qstrList.cbegin(); i != qstrList.cend(); ++i) { bytesVec.push_back(toFSD(*i)); @@ -299,7 +300,7 @@ namespace BlackCore return [ cstrVec = QVector(), bytesVec = std::move(bytesVec) ]() mutable { - Q_ASSERT(cstrVec.isEmpty()); + Q_ASSERT_X(cstrVec.isEmpty(), Q_FUNC_INFO, "toFSD lambda called twice"); for (auto i = bytesVec.cbegin(); i != bytesVec.cend(); ++i) { cstrVec.push_back(i->constData()); @@ -317,6 +318,7 @@ namespace BlackCore QStringList CNetworkVatlib::fromFSD(const char **cstrArray, int size) const { QStringList qstrList; + qstrList.reserve(size); for (int i = 0; i < size; ++i) { qstrList.push_back(fromFSD(cstrArray[i])); diff --git a/src/blackgui/guiactionbind.cpp b/src/blackgui/guiactionbind.cpp index 8e3fde64d..cb7a07e10 100644 --- a/src/blackgui/guiactionbind.cpp +++ b/src/blackgui/guiactionbind.cpp @@ -49,7 +49,7 @@ namespace BlackGui const bool hasIcon = !action->icon().isNull(); CGuiActionBindHandler *bindHandler = new CGuiActionBindHandler(action); - CActionBinding actionBinding(new CActionBind(pathNew, hasIcon ? action->icon().pixmap(CIcons::empty16().size()) : CIcons::empty16(), bindHandler, &CGuiActionBindHandler::boundFunction, [bindHandler]() { CGuiActionBindHandler::actionBindWasDestroyed(bindHandler); })); + CActionBinding actionBinding(CActionBinding::create(pathNew, hasIcon ? action->icon().pixmap(CIcons::empty16().size()) : CIcons::empty16(), bindHandler, &CGuiActionBindHandler::boundFunction, [bindHandler]() { CGuiActionBindHandler::actionBindWasDestroyed(bindHandler); })); bindHandler->m_index = actionBinding->getIndex(); boundActions.append(actionBinding); // takes ownership } @@ -64,7 +64,7 @@ namespace BlackGui CGuiActionBindHandler::appendPath(path, button->text()).remove('&'); // remove E&xit key codes CGuiActionBindHandler *bindHandler = new CGuiActionBindHandler(button); const bool hasIcon = !button->icon().isNull(); - CActionBinding actionBinding(new CActionBind(pathNew, hasIcon ? button->icon().pixmap(CIcons::empty16().size()) : CIcons::empty16(), bindHandler, &CGuiActionBindHandler::boundFunction, [bindHandler]() { CGuiActionBindHandler::actionBindWasDestroyed(bindHandler); })); + CActionBinding actionBinding(CActionBinding::create(pathNew, hasIcon ? button->icon().pixmap(CIcons::empty16().size()) : CIcons::empty16(), bindHandler, &CGuiActionBindHandler::boundFunction, [bindHandler]() { CGuiActionBindHandler::actionBindWasDestroyed(bindHandler); })); bindHandler->m_index = actionBinding->getIndex(); return actionBinding; } diff --git a/src/blackinput/win/keyboardwindows.cpp b/src/blackinput/win/keyboardwindows.cpp index 784b086b4..1602f7449 100644 --- a/src/blackinput/win/keyboardwindows.cpp +++ b/src/blackinput/win/keyboardwindows.cpp @@ -14,51 +14,55 @@ using namespace BlackMisc::Input; namespace BlackInput { - static QHash keyMapping + static const auto &keyMapping() { - { '0', Key_0 }, - { '1', Key_1 }, - { '2', Key_2 }, - { '3', Key_3 }, - { '4', Key_4 }, - { '5', Key_5 }, - { '6', Key_6 }, - { '7', Key_7 }, - { '8', Key_8 }, - { '9', Key_9 }, - { 'A', Key_A }, - { 'B', Key_B }, - { 'C', Key_C }, - { 'D', Key_D }, - { 'E', Key_E }, - { 'F', Key_F }, - { 'G', Key_G }, - { 'H', Key_H }, - { 'I', Key_I }, - { 'J', Key_J }, - { 'K', Key_K }, - { 'L', Key_L }, - { 'M', Key_M }, - { 'N', Key_N }, - { 'O', Key_O }, - { 'P', Key_P }, - { 'Q', Key_Q }, - { 'R', Key_R }, - { 'S', Key_S }, - { 'T', Key_T }, - { 'U', Key_U }, - { 'V', Key_V }, - { 'W', Key_W }, - { 'X', Key_X }, - { 'Y', Key_Y }, - { 'Z', Key_Z }, - { VK_LSHIFT, Key_ShiftLeft }, - { VK_RSHIFT, Key_ShiftRight }, - { VK_LCONTROL, Key_ControlLeft }, - { VK_RCONTROL, Key_ControlRight }, - { VK_LMENU, Key_AltLeft }, - { VK_RMENU, Key_AltRight }, - }; + static const QHash hash + { + { '0', Key_0 }, + { '1', Key_1 }, + { '2', Key_2 }, + { '3', Key_3 }, + { '4', Key_4 }, + { '5', Key_5 }, + { '6', Key_6 }, + { '7', Key_7 }, + { '8', Key_8 }, + { '9', Key_9 }, + { 'A', Key_A }, + { 'B', Key_B }, + { 'C', Key_C }, + { 'D', Key_D }, + { 'E', Key_E }, + { 'F', Key_F }, + { 'G', Key_G }, + { 'H', Key_H }, + { 'I', Key_I }, + { 'J', Key_J }, + { 'K', Key_K }, + { 'L', Key_L }, + { 'M', Key_M }, + { 'N', Key_N }, + { 'O', Key_O }, + { 'P', Key_P }, + { 'Q', Key_Q }, + { 'R', Key_R }, + { 'S', Key_S }, + { 'T', Key_T }, + { 'U', Key_U }, + { 'V', Key_V }, + { 'W', Key_W }, + { 'X', Key_X }, + { 'Y', Key_Y }, + { 'Z', Key_Z }, + { VK_LSHIFT, Key_ShiftLeft }, + { VK_RSHIFT, Key_ShiftRight }, + { VK_LCONTROL, Key_ControlLeft }, + { VK_RCONTROL, Key_ControlRight }, + { VK_LMENU, Key_AltLeft }, + { VK_RMENU, Key_AltRight }, + }; + return hash; + } static CKeyboardWindows *g_keyboardWindows = nullptr; @@ -87,13 +91,13 @@ namespace BlackInput BlackMisc::Input::CHotkeyCombination oldCombination(m_keyCombination); if ((event == WM_KEYDOWN) || (event == WM_SYSKEYDOWN)) { - auto key = keyMapping.value(vkcode); + auto key = keyMapping().value(vkcode); if (key == Key_Unknown) { return; } m_keyCombination.addKeyboardKey(CKeyboardKey(key)); } else if ((event == WM_KEYUP) || (event == WM_SYSKEYUP) ) { - auto key = keyMapping.value(vkcode); + auto key = keyMapping().value(vkcode); if (key == Key_Unknown) { return; } m_keyCombination.removeKeyboardKey(CKeyboardKey(key)); } diff --git a/src/blackmisc/applicationinfolist.cpp b/src/blackmisc/applicationinfolist.cpp index 5633406a5..207aaece1 100644 --- a/src/blackmisc/applicationinfolist.cpp +++ b/src/blackmisc/applicationinfolist.cpp @@ -30,6 +30,7 @@ namespace BlackMisc QStringList CApplicationInfoList::processNames() const { QStringList names; + names.reserve(size()); for (const CApplicationInfo &info : *this) { names.append(info.processInfo().processName()); diff --git a/src/blackmisc/aviation/airport.h b/src/blackmisc/aviation/airport.h index 3b410f14a..aebfc5c9b 100644 --- a/src/blackmisc/aviation/airport.h +++ b/src/blackmisc/aviation/airport.h @@ -97,7 +97,7 @@ namespace BlackMisc //! Elevation //! \sa setGeodeticHeight - void setElevation(const BlackMisc::Aviation::CAltitude &elevation) { return this->m_position.setGeodeticHeight(elevation); } + void setElevation(const BlackMisc::Aviation::CAltitude &elevation) { this->m_position.setGeodeticHeight(elevation); } //! Is the airport still active? bool isOperating() const { return m_operating; } diff --git a/src/blackmisc/aviation/callsign.cpp b/src/blackmisc/aviation/callsign.cpp index 222ef7684..932944abf 100644 --- a/src/blackmisc/aviation/callsign.cpp +++ b/src/blackmisc/aviation/callsign.cpp @@ -181,7 +181,7 @@ namespace BlackMisc this->m_telephonyDesignator = variant.toQString(); break; default: - return CValueObject::setPropertyByIndex(index, variant); + CValueObject::setPropertyByIndex(index, variant); } } diff --git a/src/blackmisc/aviation/selcal.cpp b/src/blackmisc/aviation/selcal.cpp index 6fe5c8ff2..ad7f7233f 100644 --- a/src/blackmisc/aviation/selcal.cpp +++ b/src/blackmisc/aviation/selcal.cpp @@ -40,6 +40,7 @@ namespace BlackMisc { QList f; if (!CSelcal::isValidCode(this->m_code)) return f; + f.reserve(this->m_code.length()); for (int pos = 0; pos < this->m_code.length(); pos++) { f.append(CSelcal::audioFrequencyEquivalent(this->m_code.at(pos))); diff --git a/src/blackmisc/db/dbinfo.cpp b/src/blackmisc/db/dbinfo.cpp index 4099c2223..93858d7e9 100644 --- a/src/blackmisc/db/dbinfo.cpp +++ b/src/blackmisc/db/dbinfo.cpp @@ -107,9 +107,14 @@ namespace BlackMisc this->setEntity(static_cast(variant.toInt())); break; default: - return (IDatastoreObjectWithIntegerKey::canHandleIndex(index)) ? - IDatastoreObjectWithIntegerKey::setPropertyByIndex(index, variant) : - CValueObject::setPropertyByIndex(index, variant); + if (IDatastoreObjectWithIntegerKey::canHandleIndex(index)) + { + IDatastoreObjectWithIntegerKey::setPropertyByIndex(index, variant); + } + else + { + CValueObject::setPropertyByIndex(index, variant); + } break; } } diff --git a/src/blackmisc/jsonexception.cpp b/src/blackmisc/jsonexception.cpp index b97d4a0fe..3da3199ac 100644 --- a/src/blackmisc/jsonexception.cpp +++ b/src/blackmisc/jsonexception.cpp @@ -39,7 +39,7 @@ namespace BlackMisc QStringList list; for (const auto scope : BlackMisc::as_const(jsonStack())) { - list.push_back(scope->m_string ? *scope->m_string : scope->m_latin1); + list.push_back(scope->m_string ? *scope->m_string : scope->m_latin1); // clazy:exclude=reserve-candidates if (scope->m_index >= 0) { list.back() += "[" % QString::number(scope->m_index) % "]"; } } return list.isEmpty() ? QStringLiteral("") : list.join('.'); diff --git a/src/blackmisc/network/rolelist.cpp b/src/blackmisc/network/rolelist.cpp index 02239bda4..50959246d 100644 --- a/src/blackmisc/network/rolelist.cpp +++ b/src/blackmisc/network/rolelist.cpp @@ -46,6 +46,7 @@ namespace BlackMisc QString CRoleList::namesAsString(const QString &separator) const { QStringList rolesString; + rolesString.reserve(size()); for (const CRole &role : (*this)) { rolesString.append(role.getName()); diff --git a/src/blackmisc/simulation/aircraftmodellist.cpp b/src/blackmisc/simulation/aircraftmodellist.cpp index c590a70f0..cda73a690 100644 --- a/src/blackmisc/simulation/aircraftmodellist.cpp +++ b/src/blackmisc/simulation/aircraftmodellist.cpp @@ -605,6 +605,7 @@ namespace BlackMisc QStringList CAircraftModelList::toCompleterStrings(bool sorted) const { QStringList c; + c.reserve(size()); for (const CAircraftModel &model : *this) { c.append(model.getModelString()); diff --git a/src/blackmisc/simulation/fscommon/vpilotmodelruleset.cpp b/src/blackmisc/simulation/fscommon/vpilotmodelruleset.cpp index 9c0277cd5..f87eedd53 100644 --- a/src/blackmisc/simulation/fscommon/vpilotmodelruleset.cpp +++ b/src/blackmisc/simulation/fscommon/vpilotmodelruleset.cpp @@ -51,6 +51,7 @@ namespace BlackMisc QStringList CVPilotModelRuleSet::toUpper(const QStringList &stringList) { QStringList upper; + upper.reserve(stringList.size()); for (const QString &s : stringList) { upper.append(s.toUpper()); @@ -61,6 +62,7 @@ namespace BlackMisc QStringList CVPilotModelRuleSet::getSortedModelNames() const { QStringList ms; + ms.reserve(size()); for (const CVPilotModelRule &rule : (*this)) { ms.append(rule.getModelName()); diff --git a/src/blackmisc/simulation/remoteaircraftprovider.cpp b/src/blackmisc/simulation/remoteaircraftprovider.cpp index 6f5d6c719..dfabbc4e0 100644 --- a/src/blackmisc/simulation/remoteaircraftprovider.cpp +++ b/src/blackmisc/simulation/remoteaircraftprovider.cpp @@ -103,7 +103,7 @@ namespace BlackMisc void CRemoteAircraftAware::updateMarkAllAsNotRendered() { Q_ASSERT_X(this->m_remoteAircraftProvider, Q_FUNC_INFO, "No object available"); - return this->m_remoteAircraftProvider->updateMarkAllAsNotRendered(); + this->m_remoteAircraftProvider->updateMarkAllAsNotRendered(); } bool CRemoteAircraftAware::isRemoteAircraftSupportingParts(const CCallsign &callsign) const diff --git a/src/blackmisc/simulation/xplane/xplaneutil.cpp b/src/blackmisc/simulation/xplane/xplaneutil.cpp index cd5601cbb..02e078cf0 100644 --- a/src/blackmisc/simulation/xplane/xplaneutil.cpp +++ b/src/blackmisc/simulation/xplane/xplaneutil.cpp @@ -44,7 +44,7 @@ namespace BlackMisc while (!ts.atEnd()) { QString pathToCheck = ts.readLine(); - if (QFileInfo(pathToCheck).exists()) { lastLine = pathToCheck; } + if (QFileInfo::exists(pathToCheck)) { lastLine = pathToCheck; } } return lastLine; } diff --git a/src/blackmisc/test/test.cpp b/src/blackmisc/test/test.cpp index 8872f0186..a47a9972d 100644 --- a/src/blackmisc/test/test.cpp +++ b/src/blackmisc/test/test.cpp @@ -15,6 +15,7 @@ namespace BlackMisc { CTestBase::CTestBase(int argc, const char *const *argv) { + m_arguments.reserve(argc); for (int i = 0; i < argc; ++i) { m_arguments.append(argv[i]); diff --git a/src/blackmisc/test/testservice.cpp b/src/blackmisc/test/testservice.cpp index 00b15b2a7..cfda5bf35 100644 --- a/src/blackmisc/test/testservice.cpp +++ b/src/blackmisc/test/testservice.cpp @@ -344,6 +344,7 @@ namespace BlackMisc { if (m_verbose) out() << "Pid: " << CTestService::getPid() << " getObjectPaths" << endl; QList paths; + paths.reserve(n); for (int i = 0; i < n; i++) { paths.append(QDBusObjectPath(ObjectPath())); diff --git a/src/blackmisc/weather/weathergridprovider.cpp b/src/blackmisc/weather/weathergridprovider.cpp index 575d72311..a1b1b22d4 100644 --- a/src/blackmisc/weather/weathergridprovider.cpp +++ b/src/blackmisc/weather/weathergridprovider.cpp @@ -20,7 +20,7 @@ namespace BlackMisc const BlackMisc::CSlot &callback) { Q_ASSERT_X(this->m_weatherGridProvider, Q_FUNC_INFO, "No object available"); - return this->m_weatherGridProvider->requestWeatherGrid(weatherGrid, callback); + this->m_weatherGridProvider->requestWeatherGrid(weatherGrid, callback); } } // namespace diff --git a/src/plugins/weatherdata/gfs/weatherdatagfs.cpp b/src/plugins/weatherdata/gfs/weatherdatagfs.cpp index e9e296c99..4b6090fec 100644 --- a/src/plugins/weatherdata/gfs/weatherdatagfs.cpp +++ b/src/plugins/weatherdata/gfs/weatherdatagfs.cpp @@ -181,6 +181,7 @@ namespace BlackWxPlugin directory = directory.arg(hourLastPublishedCycle, 2, 10, QLatin1Char('0')); QStringList params; + params.reserve(grib2Levels.size() + grib2Variables.size() + 6); params.append("file=" + filename); for (const auto &level : grib2Levels) { diff --git a/src/xbus/service.cpp b/src/xbus/service.cpp index 631e501e4..271be8dbe 100644 --- a/src/xbus/service.cpp +++ b/src/xbus/service.cpp @@ -13,6 +13,8 @@ #include #include +// clazy:excludeall=reserve-candidates + namespace XBus { diff --git a/src/xbus/service.h b/src/xbus/service.h index f562775ee..fc709f957 100644 --- a/src/xbus/service.h +++ b/src/xbus/service.h @@ -215,6 +215,7 @@ namespace XBus QList getEngineN1Percentage() const { QList list; + list.reserve(getNumberOfEngines()); for (int engineNumber = 0; engineNumber < getNumberOfEngines(); ++engineNumber) list.append(m_enginesN1Percentage.getAt(engineNumber));