From 21dc522200141d9473b03efa6600a8603a40ba53 Mon Sep 17 00:00:00 2001 From: Adam Treat Date: Tue, 2 May 2023 15:02:25 -0400 Subject: [PATCH] Don't block the GUI when reloading via combobox. --- chat.cpp | 3 ++- main.qml | 2 +- qml/ChatDrawer.qml | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/chat.cpp b/chat.cpp index 2daca6e5..e234d9d6 100644 --- a/chat.cpp +++ b/chat.cpp @@ -25,18 +25,19 @@ Chat::Chat(QObject *parent) connect(this, &Chat::unloadRequested, m_llmodel, &ChatLLM::unload, Qt::QueuedConnection); connect(this, &Chat::reloadRequested, m_llmodel, &ChatLLM::reload, Qt::QueuedConnection); connect(this, &Chat::generateNameRequested, m_llmodel, &ChatLLM::generateName, Qt::QueuedConnection); + connect(this, &Chat::setThreadCountRequested, m_llmodel, &ChatLLM::setThreadCount, Qt::QueuedConnection); // The following are blocking operations and will block the gui thread, therefore must be fast // to respond to connect(this, &Chat::regenerateResponseRequested, m_llmodel, &ChatLLM::regenerateResponse, Qt::BlockingQueuedConnection); connect(this, &Chat::resetResponseRequested, m_llmodel, &ChatLLM::resetResponse, Qt::BlockingQueuedConnection); connect(this, &Chat::resetContextRequested, m_llmodel, &ChatLLM::resetContext, Qt::BlockingQueuedConnection); - connect(this, &Chat::setThreadCountRequested, m_llmodel, &ChatLLM::setThreadCount, Qt::QueuedConnection); } void Chat::reset() { stopGenerating(); + qDebug() << "reset blocking"; emit resetContextRequested(); // blocking queued connection m_id = Network::globalInstance()->generateUniqueId(); emit idChanged(); diff --git a/main.qml b/main.qml index a2ab2cb4..3dc7c0cf 100644 --- a/main.qml +++ b/main.qml @@ -171,8 +171,8 @@ Window { onActivated: { currentChat.stopGenerating() - currentChat.modelName = comboBox.currentText currentChat.reset(); + currentChat.modelName = comboBox.currentText } } } diff --git a/qml/ChatDrawer.qml b/qml/ChatDrawer.qml index 11e76383..6b69dc45 100644 --- a/qml/ChatDrawer.qml +++ b/qml/ChatDrawer.qml @@ -343,7 +343,8 @@ Drawer { } onClicked: { - downloadClicked() } + downloadClicked() + } } } } \ No newline at end of file