From 2a81429d0ab803da08b07bdb5d11e6ca4f1dd251 Mon Sep 17 00:00:00 2001 From: Konstantin Isakov Date: Fri, 15 May 2009 12:15:08 +0000 Subject: [PATCH] +! Clear group instances before reloading dictionaries. Hopefully this would fix problems under Windows, where only one file mapping can exist. --- src/editdictionaries.cc | 5 +++++ src/editdictionaries.hh | 3 +++ src/mainwindow.cc | 4 +++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/editdictionaries.cc b/src/editdictionaries.cc index 0ab182d1..2d282dd7 100644 --- a/src/editdictionaries.cc +++ b/src/editdictionaries.cc @@ -9,8 +9,10 @@ using std::vector; EditDictionaries::EditDictionaries( QWidget * parent, Config::Class & cfg_, vector< sptr< Dictionary::Class > > & dictionaries_, + Instances::Groups & groupInstances_, QNetworkAccessManager & dictNetMgr_ ): QDialog( parent ), cfg( cfg_ ), dictionaries( dictionaries_ ), + groupInstances( groupInstances_ ), dictNetMgr( dictNetMgr_ ), origCfg( cfg ), sources( this, cfg.paths, cfg.soundDirs, cfg.hunspell, cfg.transliteration, @@ -121,6 +123,9 @@ void EditDictionaries::acceptChangedSources() cfg.transliteration = sources.getTransliteration(); cfg.mediawikis = sources.getMediaWikis(); + groupInstances.clear(); // Those hold pointers to dictionaries, we need to + // free them. + loadDictionaries( this, true, cfg, dictionaries, dictNetMgr ); } diff --git a/src/editdictionaries.hh b/src/editdictionaries.hh index 35e2de3e..e9944bcd 100644 --- a/src/editdictionaries.hh +++ b/src/editdictionaries.hh @@ -9,6 +9,7 @@ #include "ui_editdictionaries.h" #include "sources.hh" #include "groups.hh" +#include "instances.hh" #include class EditDictionaries: public QDialog @@ -19,6 +20,7 @@ public: EditDictionaries( QWidget * parent, Config::Class & cfg, std::vector< sptr< Dictionary::Class > > & dictionaries, + Instances::Groups & groupInstances, // We only clear those on rescan QNetworkAccessManager & dictNetMgr ); /// Returns true if any changes to the 'dictionaries' vector passed were done. @@ -51,6 +53,7 @@ private: Config::Class & cfg; std::vector< sptr< Dictionary::Class > > & dictionaries; + Instances::Groups & groupInstances; QNetworkAccessManager & dictNetMgr; // Backed up to decide later if something was changed or not diff --git a/src/mainwindow.cc b/src/mainwindow.cc index cbb5735a..87bfc65a 100644 --- a/src/mainwindow.cc +++ b/src/mainwindow.cc @@ -627,7 +627,7 @@ void MainWindow::editDictionaries() hotkeyWrapper.reset(); // No hotkeys while we're editing dictionaries scanPopup.reset(); // No scan popup either. No one should use dictionaries. - EditDictionaries dicts( this, cfg, dictionaries, dictNetMgr ); + EditDictionaries dicts( this, cfg, dictionaries, groupInstances, dictNetMgr ); dicts.exec(); @@ -1389,6 +1389,8 @@ void MainWindow::on_rescanFiles_activated() hotkeyWrapper.reset(); // No hotkeys while we're editing dictionaries scanPopup.reset(); // No scan popup either. No one should use dictionaries. + groupInstances.clear(); // Release all the dictionaries they hold + loadDictionaries( this, true, cfg, dictionaries, dictNetMgr ); updateGroupList();