Skip to content

Commit

Permalink
read thesaurus database only when needed the first time
Browse files Browse the repository at this point in the history
saves some 70 MB of memory
  • Loading branch information
sunderme committed Nov 11, 2023
1 parent e4c27a9 commit 8d79f44
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/texstudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4151,6 +4151,10 @@ void Texstudio::editSpell()

void Texstudio::editThesaurus(int line, int col)
{
if(!mThesaurusWasStarted){
ThesaurusDialog::prepareDatabase(configManager.parseDir(configManager.thesaurus_database));
mThesaurusWasStarted=true;
}
if (!ThesaurusDialog::retrieveDatabase()) {
QMessageBox::warning(this, tr("Error"), tr("Can't load Thesaurus Database"));
return;
Expand Down Expand Up @@ -4417,7 +4421,6 @@ void Texstudio::readSettings(bool reread)
spellerManager.setDefaultSpeller(configManager.spellLanguage);

ThesaurusDialog::setUserPath(configManager.configFileNameBase);
ThesaurusDialog::prepareDatabase(configManager.parseDir(configManager.thesaurus_database));

symbolListModel = new SymbolListModel(config->value("Symbols/UsageCount").toMap(),
config->value("Symbols/FavoriteIDs").toStringList());
Expand Down Expand Up @@ -6736,7 +6739,10 @@ void Texstudio::generalOptions()

symbolListModel->setDarkmode(darkMode);

ThesaurusDialog::prepareDatabase(configManager.parseDir(configManager.thesaurus_database));
if(mThesaurusWasStarted){
// replace database with new one
ThesaurusDialog::prepareDatabase(configManager.parseDir(configManager.thesaurus_database));
}
if (additionalBibPaths != configManager.additionalBibPaths) documents.updateBibFiles(true);

// update syntaxChecking with alls docs
Expand Down
2 changes: 2 additions & 0 deletions src/texstudio.h
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,8 @@ private slots:

StructureEntry *currentSection;

bool mThesaurusWasStarted=false;

public:
Q_PROPERTY(QString clipboard READ clipboardText WRITE setClipboardText)
Q_INVOKABLE QString clipboardText(const QClipboard::Mode &mode = QClipboard::Clipboard) const;
Expand Down

0 comments on commit 8d79f44

Please sign in to comment.