From ba9b13d9e662789b7e7c801ede95431243eb88c4 Mon Sep 17 00:00:00 2001 From: Konstantin Isakov Date: Sun, 17 May 2009 22:02:54 +0000 Subject: [PATCH] * On initial load do deferred dictionary init at the very end. --- src/loaddictionaries.cc | 10 ++++++++-- src/loaddictionaries.hh | 8 +++++++- src/mainwindow.cc | 5 ++++- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/loaddictionaries.cc b/src/loaddictionaries.cc index 64443739..6f51d158 100644 --- a/src/loaddictionaries.cc +++ b/src/loaddictionaries.cc @@ -158,7 +158,8 @@ void LoadDictionaries::indexingDictionary( string const & dictionaryName ) throw void loadDictionaries( QWidget * parent, bool showInitially, Config::Class const & cfg, std::vector< sptr< Dictionary::Class > > & dictionaries, - QNetworkAccessManager & dictNetMgr ) + QNetworkAccessManager & dictNetMgr, + bool doDeferredInit_ ) { dictionaries.clear(); @@ -232,7 +233,12 @@ void loadDictionaries( QWidget * parent, bool showInitially, // Run deferred inits + if ( doDeferredInit_ ) + doDeferredInit( dictionaries ); +} + +void doDeferredInit( std::vector< sptr< Dictionary::Class > > & dictionaries ) +{ for( unsigned x = 0; x < dictionaries.size(); ++x ) dictionaries[ x ]->deferredInit(); } - diff --git a/src/loaddictionaries.hh b/src/loaddictionaries.hh index 4a6adffa..38fc316d 100644 --- a/src/loaddictionaries.hh +++ b/src/loaddictionaries.hh @@ -53,10 +53,16 @@ private: /// Loads all dictionaries mentioned in the configuration passed, into the /// supplied array. When necessary, a window would pop up describing the process. /// If showInitially is passed as true, the window will always popup. +/// If doDeferredInit is true (default), doDeferredInit() is done on all +/// dictionaries at the end. void loadDictionaries( QWidget * parent, bool showInitially, Config::Class const & cfg, std::vector< sptr< Dictionary::Class > > &, - QNetworkAccessManager & dictNetMgr ); + QNetworkAccessManager & dictNetMgr, + bool doDeferredInit = true ); +/// Runs deferredInit() on all the given dictionaries. Useful when +/// loadDictionaries() was previously called with doDeferredInit = false. +void doDeferredInit( std::vector< sptr< Dictionary::Class > > & ); #endif diff --git a/src/mainwindow.cc b/src/mainwindow.cc index bbdf7574..470a9c78 100644 --- a/src/mainwindow.cc +++ b/src/mainwindow.cc @@ -269,6 +269,9 @@ MainWindow::MainWindow( Config::Class & cfg_ ): this, SLOT( checkForNewRelease() ) ); prepareNewReleaseChecks(); + + // makeDictionaries() didn't do deferred init - we do it here, at the end. + doDeferredInit( dictionaries ); } MainWindow::~MainWindow() @@ -397,7 +400,7 @@ void MainWindow::makeDictionaries() wordFinder.clear(); - loadDictionaries( this, isVisible(), cfg, dictionaries, dictNetMgr ); + loadDictionaries( this, isVisible(), cfg, dictionaries, dictNetMgr, false ); updateStatusLine(); updateGroupList();