Skip to content

Commit f114197

Browse files
committed
fixup! Fix "Use QLatin1String("") or QString() instead of an empty QStringLiteral [-Wclazy-empty-qstringliteral]" error
1 parent 99fed94 commit f114197

2 files changed

Lines changed: 14 additions & 23 deletions

File tree

src/controllers/scripting/legacy/controllerscriptenginelegacy.cpp

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#include "controllers/scripting/legacy/controllerscriptenginelegacy.h"
22

3+
#include <memory>
4+
35
#ifdef MIXXX_USE_QML
46
#include <QDirIterator>
57
#include <QQmlEngine>
@@ -114,13 +116,8 @@ bool ControllerScriptEngineLegacy::callShutdownFunction() {
114116
return callFunctionOnObjects(m_scriptFunctionPrefixes, "shutdown");
115117
#ifdef MIXXX_USE_QML
116118
} else {
117-
QHashIterator<QString, mixxx::qml::QmlMixxxControllerScreen*> i(m_rootItems);
118119
bool success = true;
119-
while (i.hasNext()) {
120-
i.next();
121-
const auto& screen = i.value();
122-
const QString& screenIdentifier = i.key();
123-
120+
for (const auto& [screenIdentifier, screen] : m_rootItems) {
124121
if (!screen->getShutdown().isCallable()) {
125122
qCDebug(m_logger) << "QML Scene for screen" << screenIdentifier
126123
<< "has no valid shutdown method.";
@@ -159,12 +156,7 @@ bool ControllerScriptEngineLegacy::callInitFunction() {
159156
return callFunctionOnObjects(m_scriptFunctionPrefixes, "init", args, true);
160157
#ifdef MIXXX_USE_QML
161158
} else {
162-
QHashIterator<QString, mixxx::qml::QmlMixxxControllerScreen*> i(m_rootItems);
163-
while (i.hasNext()) {
164-
i.next();
165-
const auto& screen = i.value();
166-
const QString& screenIdentifier = i.key();
167-
159+
for (const auto& [screenIdentifier, screen] : m_rootItems) {
168160
if (!screen->getInit().isCallable()) {
169161
qCDebug(m_logger) << "QML Scene for screen" << screenIdentifier
170162
<< "has no valid init method.";
@@ -480,7 +472,7 @@ bool ControllerScriptEngineLegacy::bindSceneToScreen(
480472
// evaluating it.
481473
watchFilePath(qmlFile.file.absoluteFilePath());
482474

483-
auto* pScene = loadQMLFile(qmlFile, pScreen);
475+
auto pScene = loadQMLFile(qmlFile, pScreen);
484476
if (!pScene) {
485477
VERIFY_OR_DEBUG_ASSERT(!pScreen->isValid() ||
486478
!pScreen->isRunning() || pScreen->stop()) {
@@ -494,7 +486,7 @@ bool ControllerScriptEngineLegacy::bindSceneToScreen(
494486
this,
495487
&ControllerScriptEngineLegacy::handleScreenFrame);
496488
m_renderingScreens.insert(screenIdentifier, pScreen);
497-
m_rootItems.insert(screenIdentifier, pScene);
489+
m_rootItems.emplace(screenIdentifier, std::move(pScene));
498490
// In case a rendering issue occurs, we need to shutdown the controller
499491
// since its only purpose is to render screens. This might not be the case
500492
// in the future controller modules
@@ -519,7 +511,7 @@ void ControllerScriptEngineLegacy::handleScreenFrame(
519511
return;
520512
};
521513

522-
auto* pScreen = m_rootItems.value(screenInfo.identifier);
514+
auto& pScreen = m_rootItems.at(screenInfo.identifier);
523515

524516
if (CmdlineArgs::Instance().getControllerPreviewScreens()) {
525517
QImage screenDebug(frame);
@@ -742,7 +734,7 @@ bool ControllerScriptEngineLegacy::evaluateScriptFile(const QFileInfo& scriptFil
742734
}
743735

744736
#ifdef MIXXX_USE_QML
745-
mixxx::qml::QmlMixxxControllerScreen* ControllerScriptEngineLegacy::loadQMLFile(
737+
std::unique_ptr<mixxx::qml::QmlMixxxControllerScreen> ControllerScriptEngineLegacy::loadQMLFile(
746738
const LegacyControllerMapping::ScriptFileInfo& qmlScript,
747739
std::shared_ptr<ControllerRenderingEngine> pScreen) {
748740
VERIFY_OR_DEBUG_ASSERT(m_pJSEngine ||
@@ -806,7 +798,7 @@ mixxx::qml::QmlMixxxControllerScreen* ControllerScriptEngineLegacy::loadQMLFile(
806798
mixxx::qml::QmlMixxxControllerScreen* rootItem =
807799
qobject_cast<mixxx::qml::QmlMixxxControllerScreen*>(pRootObject);
808800
if (!rootItem) {
809-
qWarning("run: Not a QQuickItem");
801+
qWarning("run: Not a MixxxControllerScreen");
810802
delete pRootObject;
811803
return nullptr;
812804
}
@@ -820,7 +812,7 @@ mixxx::qml::QmlMixxxControllerScreen* ControllerScriptEngineLegacy::loadQMLFile(
820812
rootItem->setHeight(pScreen->quickWindow()->height());
821813
}
822814

823-
return rootItem;
815+
return std::unique_ptr<mixxx::qml::QmlMixxxControllerScreen>(rootItem);
824816
}
825817
#endif
826818

src/controllers/scripting/legacy/controllerscriptenginelegacy.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <QJSEngine>
55
#include <QJSValue>
66
#include <QMessageBox>
7+
#include <memory>
78
#ifdef MIXXX_USE_QML
89
#include <QMetaMethod>
910
#endif
@@ -89,8 +90,7 @@ class ControllerScriptEngineLegacy : public ControllerScriptEngineBase {
8990
std::shared_ptr<ControllerRenderingEngine> pScreen);
9091
void extractTransformFunction(const QMetaObject* metaObject, const QString& screenIdentifier);
9192

92-
// The returned QmlMixxxController will be owned and managed by the pScreen
93-
mixxx::qml::QmlMixxxControllerScreen* loadQMLFile(
93+
std::unique_ptr<mixxx::qml::QmlMixxxControllerScreen> loadQMLFile(
9494
const LegacyControllerMapping::ScriptFileInfo& qmlScript,
9595
std::shared_ptr<ControllerRenderingEngine> pScreen);
9696

@@ -120,9 +120,8 @@ class ControllerScriptEngineLegacy : public ControllerScriptEngineBase {
120120
QHash<QString, std::shared_ptr<ControllerRenderingEngine>> m_renderingScreens;
121121
// Contains all the scenes loaded for this mapping. Key is the scene
122122
// identifier (LegacyControllerMapping::ScreenInfo::identifier), value in
123-
// the QML root item. Note that the pointer is owned by the QML scene which
124-
// will free them on shutdown (ControllerScriptEngineLegacy::shutdown)
125-
QHash<QString, mixxx::qml::QmlMixxxControllerScreen*> m_rootItems;
123+
// the QML root item.
124+
std::unordered_map<QString, std::unique_ptr<mixxx::qml::QmlMixxxControllerScreen>> m_rootItems;
126125
QList<LegacyControllerMapping::QMLModuleInfo> m_modules;
127126
QList<LegacyControllerMapping::ScreenInfo> m_infoScreens;
128127
QString m_resourcePath{QStringLiteral(".")};

0 commit comments

Comments
 (0)