From 9a3dd8815d2085e18650c328cd641fcad076a665 Mon Sep 17 00:00:00 2001 From: Adam Treat Date: Fri, 17 Nov 2023 13:27:17 -0500 Subject: [PATCH] Fix GUI hang with localdocs by removing file system watcher in modellist. --- gpt4all-chat/download.cpp | 3 ++- gpt4all-chat/modellist.cpp | 6 +----- gpt4all-chat/modellist.h | 4 ++-- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/gpt4all-chat/download.cpp b/gpt4all-chat/download.cpp index b3d0d990..eafa562c 100644 --- a/gpt4all-chat/download.cpp +++ b/gpt4all-chat/download.cpp @@ -385,8 +385,9 @@ void HashAndSaveFile::hashAndSave(const QString &expectedHash, const QString &sa qWarning() << errorString; tempFile->close(); emit hashAndSaveFinished(false, errorString, tempFile, modelReply); - return; } + + ModelList::globalInstance()->updateModelsFromDirectory(); } void Download::handleModelDownloadFinished() diff --git a/gpt4all-chat/modellist.cpp b/gpt4all-chat/modellist.cpp index 8f058347..3403cb8c 100644 --- a/gpt4all-chat/modellist.cpp +++ b/gpt4all-chat/modellist.cpp @@ -264,11 +264,7 @@ ModelList::ModelList() m_embeddingModels->setSourceModel(this); m_installedModels->setSourceModel(this); m_downloadableModels->setSourceModel(this); - m_watcher = new QFileSystemWatcher(this); - const QString exePath = QCoreApplication::applicationDirPath() + QDir::separator(); - m_watcher->addPath(exePath); - m_watcher->addPath(MySettings::globalInstance()->modelPath()); - connect(m_watcher, &QFileSystemWatcher::directoryChanged, this, &ModelList::updateModelsFromDirectory); + connect(MySettings::globalInstance(), &MySettings::modelPathChanged, this, &ModelList::updateModelsFromDirectory); connect(MySettings::globalInstance(), &MySettings::modelPathChanged, this, &ModelList::updateModelsFromJson); connect(MySettings::globalInstance(), &MySettings::modelPathChanged, this, &ModelList::updateModelsFromSettings); diff --git a/gpt4all-chat/modellist.h b/gpt4all-chat/modellist.h index d1884266..536f3a99 100644 --- a/gpt4all-chat/modellist.h +++ b/gpt4all-chat/modellist.h @@ -320,6 +320,8 @@ public: QString incompleteDownloadPath(const QString &modelFile); bool asyncModelRequestOngoing() const { return m_asyncModelRequestOngoing; } + void updateModelsFromDirectory(); + Q_SIGNALS: void countChanged(); void embeddingModelsChanged(); @@ -333,7 +335,6 @@ private Q_SLOTS: void updateModelsFromJson(); void updateModelsFromJsonAsync(); void updateModelsFromSettings(); - void updateModelsFromDirectory(); void updateDataForSettings(); void handleModelsJsonDownloadFinished(); void handleModelsJsonDownloadErrorOccurred(QNetworkReply::NetworkError code); @@ -355,7 +356,6 @@ private: DownloadableModels *m_downloadableModels; QList m_models; QHash m_modelMap; - QFileSystemWatcher *m_watcher; bool m_asyncModelRequestOngoing; private: