From 8c6f7d976714aa78e2d8116ee1c0de5605fdc377 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Han=C3=A7erli?= <burak.hancerli@qt.io> Date: Fri, 17 Jan 2025 10:37:48 +0000 Subject: [PATCH] Fix log forwarding --- src/SettingsPage.qml | 2 +- src/backend/backend.cpp | 7 ++++--- src/backend/projectmanager.cpp | 13 ++++++++----- src/backend/projectmanager.h | 1 + 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/SettingsPage.qml b/src/SettingsPage.qml index 865b297..5547b69 100644 --- a/src/SettingsPage.qml +++ b/src/SettingsPage.qml @@ -29,7 +29,7 @@ Flickable { Layout.fillWidth: true horizontalPadding: 20 text: qsTr("Auto-scale") - subText: qsTr("Scales the project to fit to current display and orientation") + subText: qsTr("Tries to scale the project to fit to current display and orientation. May not work with all projects.") checked: backend.autoScaleProject() ? Qt.Checked : Qt.Unchecked onToggled: backend.setAutoScaleProject(checked) } diff --git a/src/backend/backend.cpp b/src/backend/backend.cpp index 8a5e82c..ccf9782 100644 --- a/src/backend/backend.cpp +++ b/src/backend/backend.cpp @@ -64,7 +64,7 @@ Backend::Backend(QObject *parent) connect(&Logger::instance(), &Logger::logMessage, this, [this](QtMsgType type, QString &msg) { // if we have any active project running, then reroute // all the logs to the dsmanager with the last project sender id - if (m_projectManager && m_projectManager->isRunning()) { + if (m_projectManager && m_lastSessionId == m_projectManager->sessionId()) { QMetaObject::invokeMethod(m_dsManager.get(), "sendProjectLogs", Qt::QueuedConnection, @@ -142,8 +142,9 @@ void Backend::initProjectManager() &ProjectManager::closingProject, this, [this](const QString &sessionId) { - // most likely the project was running from the leftover session - // (DS connected, project started, DS disconnected without stopping the project) + // if seesion ids are same, it's most likely the project was running + // from the leftover session (DS connected, project started, + // DS disconnected without stopping the project) // so we'll stop the project and do not send any signals to the DS if (sessionId != m_lastSessionId) return; diff --git a/src/backend/projectmanager.cpp b/src/backend/projectmanager.cpp index 13fed11..e1c01e7 100644 --- a/src/backend/projectmanager.cpp +++ b/src/backend/projectmanager.cpp @@ -229,7 +229,7 @@ bool ProjectManager::runProject(const QByteArray &project, const QStringList importPaths = getImportPaths(projectPath, qmlProjectFileContent); if (!isQt6Project(qmlProjectFileContent)) { - qWarning() << "This is not a Qt6 project.\nQt5 projects might work, but they are not " + qWarning() << "This is not a Qt6 project. Qt5 projects might work, but they are not " "officially supported."; } @@ -362,9 +362,8 @@ void ProjectManager::showAppWindow() connect(m_quickWindow.data(), &QQuickWindow::closing, this, [this, screen]() { qDebug() << "QML app window is closing"; disconnect(screen, &QScreen::orientationChanged, this, &ProjectManager::orientateWindow); - // this signal is connected to the lambda in the backend - // which will reset the project manager emit closingProject(m_sessionId); + m_sessionId.clear(); }); m_quickWindow->setFlags(Qt::Window | Qt::WindowStaysOnTopHint); @@ -376,12 +375,16 @@ void ProjectManager::stopProject() if (!m_quickWindow || !m_quickWindow->isVisible()) return; - m_sessionId.clear(); qDebug("Stopping the QML app window"); m_quickWindow->close(); } bool ProjectManager::isRunning() { - return m_quickWindow && m_quickWindow->isVisible(); + return !m_sessionId.isEmpty(); +} + +QString ProjectManager::sessionId() const +{ + return m_sessionId; } diff --git a/src/backend/projectmanager.h b/src/backend/projectmanager.h index ef92360..f434bbb 100644 --- a/src/backend/projectmanager.h +++ b/src/backend/projectmanager.h @@ -35,6 +35,7 @@ public: ~ProjectManager(); bool isRunning(); + QString sessionId() const; public slots: bool runProject(const QByteArray &project, -- GitLab