Skip to content

Commit

Permalink
Fix GUI hang with localdocs by removing file system watcher in modell…
Browse files Browse the repository at this point in the history
…ist.
  • Loading branch information
manyoso committed Nov 17, 2023
1 parent c1809a2 commit 9a3dd88
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
3 changes: 2 additions & 1 deletion gpt4all-chat/download.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
6 changes: 1 addition & 5 deletions gpt4all-chat/modellist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions gpt4all-chat/modellist.h
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,8 @@ class ModelList : public QAbstractListModel
QString incompleteDownloadPath(const QString &modelFile);
bool asyncModelRequestOngoing() const { return m_asyncModelRequestOngoing; }

void updateModelsFromDirectory();

Q_SIGNALS:
void countChanged();
void embeddingModelsChanged();
Expand All @@ -333,7 +335,6 @@ private Q_SLOTS:
void updateModelsFromJson();
void updateModelsFromJsonAsync();
void updateModelsFromSettings();
void updateModelsFromDirectory();
void updateDataForSettings();
void handleModelsJsonDownloadFinished();
void handleModelsJsonDownloadErrorOccurred(QNetworkReply::NetworkError code);
Expand All @@ -355,7 +356,6 @@ private Q_SLOTS:
DownloadableModels *m_downloadableModels;
QList<ModelInfo*> m_models;
QHash<QString, ModelInfo*> m_modelMap;
QFileSystemWatcher *m_watcher;
bool m_asyncModelRequestOngoing;

private:
Expand Down

0 comments on commit 9a3dd88

Please sign in to comment.