Skip to content

Commit

Permalink
fixup! Fix "Use QLatin1String("") or QString() instead of an empty QS…
Browse files Browse the repository at this point in the history
…tringLiteral [-Wclazy-empty-qstringliteral]" error
  • Loading branch information
acolombier committed Oct 19, 2024
1 parent 99fed94 commit f114197
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 23 deletions.
28 changes: 10 additions & 18 deletions src/controllers/scripting/legacy/controllerscriptenginelegacy.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "controllers/scripting/legacy/controllerscriptenginelegacy.h"

#include <memory>

#ifdef MIXXX_USE_QML
#include <QDirIterator>
#include <QQmlEngine>
Expand Down Expand Up @@ -114,13 +116,8 @@ bool ControllerScriptEngineLegacy::callShutdownFunction() {
return callFunctionOnObjects(m_scriptFunctionPrefixes, "shutdown");
#ifdef MIXXX_USE_QML
} else {
QHashIterator<QString, mixxx::qml::QmlMixxxControllerScreen*> i(m_rootItems);
bool success = true;
while (i.hasNext()) {
i.next();
const auto& screen = i.value();
const QString& screenIdentifier = i.key();

for (const auto& [screenIdentifier, screen] : m_rootItems) {
if (!screen->getShutdown().isCallable()) {
qCDebug(m_logger) << "QML Scene for screen" << screenIdentifier
<< "has no valid shutdown method.";
Expand Down Expand Up @@ -159,12 +156,7 @@ bool ControllerScriptEngineLegacy::callInitFunction() {
return callFunctionOnObjects(m_scriptFunctionPrefixes, "init", args, true);
#ifdef MIXXX_USE_QML
} else {
QHashIterator<QString, mixxx::qml::QmlMixxxControllerScreen*> i(m_rootItems);
while (i.hasNext()) {
i.next();
const auto& screen = i.value();
const QString& screenIdentifier = i.key();

for (const auto& [screenIdentifier, screen] : m_rootItems) {
if (!screen->getInit().isCallable()) {
qCDebug(m_logger) << "QML Scene for screen" << screenIdentifier
<< "has no valid init method.";
Expand Down Expand Up @@ -480,7 +472,7 @@ bool ControllerScriptEngineLegacy::bindSceneToScreen(
// evaluating it.
watchFilePath(qmlFile.file.absoluteFilePath());

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

auto* pScreen = m_rootItems.value(screenInfo.identifier);
auto& pScreen = m_rootItems.at(screenInfo.identifier);

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

#ifdef MIXXX_USE_QML
mixxx::qml::QmlMixxxControllerScreen* ControllerScriptEngineLegacy::loadQMLFile(
std::unique_ptr<mixxx::qml::QmlMixxxControllerScreen> ControllerScriptEngineLegacy::loadQMLFile(
const LegacyControllerMapping::ScriptFileInfo& qmlScript,
std::shared_ptr<ControllerRenderingEngine> pScreen) {
VERIFY_OR_DEBUG_ASSERT(m_pJSEngine ||
Expand Down Expand Up @@ -806,7 +798,7 @@ mixxx::qml::QmlMixxxControllerScreen* ControllerScriptEngineLegacy::loadQMLFile(
mixxx::qml::QmlMixxxControllerScreen* rootItem =
qobject_cast<mixxx::qml::QmlMixxxControllerScreen*>(pRootObject);
if (!rootItem) {
qWarning("run: Not a QQuickItem");
qWarning("run: Not a MixxxControllerScreen");
delete pRootObject;
return nullptr;
}
Expand All @@ -820,7 +812,7 @@ mixxx::qml::QmlMixxxControllerScreen* ControllerScriptEngineLegacy::loadQMLFile(
rootItem->setHeight(pScreen->quickWindow()->height());
}

return rootItem;
return std::unique_ptr<mixxx::qml::QmlMixxxControllerScreen>(rootItem);
}
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <QJSEngine>
#include <QJSValue>
#include <QMessageBox>
#include <memory>
#ifdef MIXXX_USE_QML
#include <QMetaMethod>
#endif
Expand Down Expand Up @@ -89,8 +90,7 @@ class ControllerScriptEngineLegacy : public ControllerScriptEngineBase {
std::shared_ptr<ControllerRenderingEngine> pScreen);
void extractTransformFunction(const QMetaObject* metaObject, const QString& screenIdentifier);

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

Expand Down Expand Up @@ -120,9 +120,8 @@ class ControllerScriptEngineLegacy : public ControllerScriptEngineBase {
QHash<QString, std::shared_ptr<ControllerRenderingEngine>> m_renderingScreens;
// Contains all the scenes loaded for this mapping. Key is the scene
// identifier (LegacyControllerMapping::ScreenInfo::identifier), value in
// the QML root item. Note that the pointer is owned by the QML scene which
// will free them on shutdown (ControllerScriptEngineLegacy::shutdown)
QHash<QString, mixxx::qml::QmlMixxxControllerScreen*> m_rootItems;
// the QML root item.
std::unordered_map<QString, std::unique_ptr<mixxx::qml::QmlMixxxControllerScreen>> m_rootItems;

Check failure on line 124 in src/controllers/scripting/legacy/controllerscriptenginelegacy.h

View workflow job for this annotation

GitHub Actions / macOS 12 arm64

no template named 'unordered_map' in namespace 'std'
QList<LegacyControllerMapping::QMLModuleInfo> m_modules;
QList<LegacyControllerMapping::ScreenInfo> m_infoScreens;
QString m_resourcePath{QStringLiteral(".")};
Expand Down

0 comments on commit f114197

Please sign in to comment.