+! Clear group instances before reloading dictionaries. Hopefully this would

fix problems under Windows, where only one file mapping can exist.
This commit is contained in:
Konstantin Isakov 2009-05-15 12:15:08 +00:00
parent 74b04ff788
commit 2a81429d0a
3 changed files with 11 additions and 1 deletions

View file

@ -9,8 +9,10 @@ using std::vector;
EditDictionaries::EditDictionaries( QWidget * parent, Config::Class & cfg_, EditDictionaries::EditDictionaries( QWidget * parent, Config::Class & cfg_,
vector< sptr< Dictionary::Class > > & dictionaries_, vector< sptr< Dictionary::Class > > & dictionaries_,
Instances::Groups & groupInstances_,
QNetworkAccessManager & dictNetMgr_ ): QNetworkAccessManager & dictNetMgr_ ):
QDialog( parent ), cfg( cfg_ ), dictionaries( dictionaries_ ), QDialog( parent ), cfg( cfg_ ), dictionaries( dictionaries_ ),
groupInstances( groupInstances_ ),
dictNetMgr( dictNetMgr_ ), dictNetMgr( dictNetMgr_ ),
origCfg( cfg ), origCfg( cfg ),
sources( this, cfg.paths, cfg.soundDirs, cfg.hunspell, cfg.transliteration, sources( this, cfg.paths, cfg.soundDirs, cfg.hunspell, cfg.transliteration,
@ -121,6 +123,9 @@ void EditDictionaries::acceptChangedSources()
cfg.transliteration = sources.getTransliteration(); cfg.transliteration = sources.getTransliteration();
cfg.mediawikis = sources.getMediaWikis(); cfg.mediawikis = sources.getMediaWikis();
groupInstances.clear(); // Those hold pointers to dictionaries, we need to
// free them.
loadDictionaries( this, true, cfg, dictionaries, dictNetMgr ); loadDictionaries( this, true, cfg, dictionaries, dictNetMgr );
} }

View file

@ -9,6 +9,7 @@
#include "ui_editdictionaries.h" #include "ui_editdictionaries.h"
#include "sources.hh" #include "sources.hh"
#include "groups.hh" #include "groups.hh"
#include "instances.hh"
#include <QNetworkAccessManager> #include <QNetworkAccessManager>
class EditDictionaries: public QDialog class EditDictionaries: public QDialog
@ -19,6 +20,7 @@ public:
EditDictionaries( QWidget * parent, Config::Class & cfg, EditDictionaries( QWidget * parent, Config::Class & cfg,
std::vector< sptr< Dictionary::Class > > & dictionaries, std::vector< sptr< Dictionary::Class > > & dictionaries,
Instances::Groups & groupInstances, // We only clear those on rescan
QNetworkAccessManager & dictNetMgr ); QNetworkAccessManager & dictNetMgr );
/// Returns true if any changes to the 'dictionaries' vector passed were done. /// Returns true if any changes to the 'dictionaries' vector passed were done.
@ -51,6 +53,7 @@ private:
Config::Class & cfg; Config::Class & cfg;
std::vector< sptr< Dictionary::Class > > & dictionaries; std::vector< sptr< Dictionary::Class > > & dictionaries;
Instances::Groups & groupInstances;
QNetworkAccessManager & dictNetMgr; QNetworkAccessManager & dictNetMgr;
// Backed up to decide later if something was changed or not // Backed up to decide later if something was changed or not

View file

@ -627,7 +627,7 @@ void MainWindow::editDictionaries()
hotkeyWrapper.reset(); // No hotkeys while we're editing dictionaries hotkeyWrapper.reset(); // No hotkeys while we're editing dictionaries
scanPopup.reset(); // No scan popup either. No one should use 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(); dicts.exec();
@ -1389,6 +1389,8 @@ void MainWindow::on_rescanFiles_activated()
hotkeyWrapper.reset(); // No hotkeys while we're editing dictionaries hotkeyWrapper.reset(); // No hotkeys while we're editing dictionaries
scanPopup.reset(); // No scan popup either. No one should use 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 ); loadDictionaries( this, true, cfg, dictionaries, dictNetMgr );
updateGroupList(); updateGroupList();