From 9cf63f67b44cc6435097dfe3b150ef32e6978628 Mon Sep 17 00:00:00 2001 From: Levi Neely <141506390+lneely@users.noreply.github.com> Date: Mon, 27 Jul 2026 21:32:31 +0200 Subject: [PATCH] gui: fix ghost process, null block.reaction crash, window counter --- gui/ChatPane.qml | 8 ++++---- gui/main-kf5.qml | 10 ++++++++++ gui/main.cpp | 5 +++++ gui/main.qml | 15 +++++++++++++++ 4 files changed, 34 insertions(+), 4 deletions(-) diff --git a/gui/ChatPane.qml b/gui/ChatPane.qml index 9a5b7a5..1550302 100644 --- a/gui/ChatPane.qml +++ b/gui/ChatPane.qml @@ -692,20 +692,20 @@ Item { anchors.right: parent.right anchors.margins: 4 z: 10 - text: block.reaction || "" + text: block ? (block.reaction || "") : "" font.pixelSize: 18 - visible: block.reaction !== "" + visible: block ? block.reaction !== "" : false } // Reaction buttons (hover only, hidden when already reacted) Row { anchors.bottom: parent.bottom anchors.right: parent.right - anchors.rightMargin: block.reaction !== "" ? 36 : 4 + anchors.rightMargin: block && block.reaction !== "" ? 36 : 4 anchors.margins: 4 z: 10 spacing: 2 - opacity: (assistantHover.hovered && block.reaction === "") ? 0.9 : 0 + opacity: (assistantHover.hovered && (block ? block.reaction : "") === "") ? 0.9 : 0 Behavior on opacity { NumberAnimation { duration: 150 } } Repeater { diff --git a/gui/main-kf5.qml b/gui/main-kf5.qml index 35f1743..d6584ca 100644 --- a/gui/main-kf5.qml +++ b/gui/main-kf5.qml @@ -11,6 +11,16 @@ ApplicationWindow { height: 600 visible: true + Component.onCompleted: activator.windowOpened() + + Component.onDestruction: { + activator.windowClosed() + if (activator.windowCount === 0 + && !(theme.closeToTray && systemTrayAvailable)) { + Qt.quit() + } + } + onClosing: { if (theme.closeToTray && systemTrayAvailable) { close.accepted = false diff --git a/gui/main.cpp b/gui/main.cpp index 2a45637..e781734 100644 --- a/gui/main.cpp +++ b/gui/main.cpp @@ -27,12 +27,16 @@ public: explicit GuiActivator(QQmlApplicationEngine *engine, QObject *parent = nullptr) : QObject(parent) , m_engine(engine) + , m_windowCount(0) { } void setWindowUrl(const QUrl &url) { m_url = url; } + int windowCount() const { return m_windowCount; } public slots: + void windowOpened() { ++m_windowCount; } + void windowClosed() { if (m_windowCount > 0) --m_windowCount; } void Activate() { const auto roots = m_engine->rootObjects(); @@ -65,6 +69,7 @@ public slots: private: QQmlApplicationEngine *m_engine; QUrl m_url; + int m_windowCount; }; static QIcon makeBrainIcon() diff --git a/gui/main.qml b/gui/main.qml index 12332f1..610e06b 100644 --- a/gui/main.qml +++ b/gui/main.qml @@ -10,6 +10,8 @@ ApplicationWindow { height: 600 visible: true + Component.onCompleted: activator.windowOpened() + onClosing: function(close) { if (theme.closeToTray && systemTrayAvailable) { close.accepted = false @@ -17,6 +19,12 @@ ApplicationWindow { } } + Component.onDestruction: { + if (typeof activator !== 'undefined' && activator) { + activator.windowClosed() + } + } + color: palette.window font.family: theme.fontFamily || Qt.application.font.family font.pointSize: theme.fontSize > 0 ? theme.fontSize : Qt.application.font.pointSize @@ -290,6 +298,13 @@ ApplicationWindow { visible: false color: palette.window + Component.onCompleted: activator.windowOpened() + Component.onDestruction: { + if (typeof activator !== 'undefined' && activator) { + activator.windowClosed() + } + } + SessionGraph { id: graphView anchors.fill: parent