------------------------------------------------------------ revno: 3208 committer: poy <p...@123gen.com> branch nick: trunk timestamp: Thu 2013-02-14 20:14:20 +0100 message: No GUI freeze when DC++ starts modified: changelog.txt win32/SplashWindow.cpp win32/main.cpp
-- lp:dcplusplus https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk Your team Dcplusplus-team is subscribed to branch lp:dcplusplus. To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk/+edit-subscription
=== modified file 'changelog.txt' --- changelog.txt 2013-02-14 16:25:20 +0000 +++ changelog.txt 2013-02-14 19:14:20 +0000 @@ -2,6 +2,7 @@ * [L#534440] [NMDC] Preserve encodings in some search results (poy) * [ADC] Fix problems after marking oneself as a favorite user * Display progress information when DC++ starts (poy) +* No GUI freeze when DC++ starts (poy) -- 0.810 2013-01-30 -- * Fix a race condition on file list download (thanks bigmuscle) === modified file 'win32/SplashWindow.cpp' --- win32/SplashWindow.cpp 2013-02-14 16:25:20 +0000 +++ win32/SplashWindow.cpp 2013-02-14 19:14:20 +0000 @@ -62,12 +62,12 @@ void SplashWindow::operator()(const string& status) { this->status = str(TF_("Loading DC++, please wait... (%1%)") % Text::toT(status)); progress = 0; - draw(); + callAsync([this] { draw(); }); } void SplashWindow::operator()(float progress) { this->progress = progress; - draw(); + callAsync([this] { draw(); }); } void SplashWindow::draw() { === modified file 'win32/main.cpp' --- win32/main.cpp 2013-02-14 16:25:20 +0000 +++ win32/main.cpp 2013-02-14 19:14:20 +0000 @@ -32,8 +32,10 @@ #include <dcpp/MerkleTree.h> #include <dcpp/File.h> #include <dcpp/Text.h> +#include <dcpp/Thread.h> #include <dcpp/MappingManager.h> #include <dcpp/ResourceManager.h> +#include <dcpp/version.h> #include <dwt/Application.h> @@ -138,25 +140,38 @@ startup(); PluginApiWin::init(); - load([splash](const string& str) { (*splash)(str); }, [splash](float progress) { (*splash)(progress); }); - - bindtextdomain(PACKAGE, LOCALEDIR); - textdomain(PACKAGE); - - if(ResourceManager::getInstance()->isRTL()) { - SetProcessDefaultLayout(LAYOUT_RTL); - } - - dwtTexts::init(); - - WinUtil::init(); - - MainWindow* wnd = new MainWindow; - WinUtil::mainWindow = wnd; - //WinUtil::mdiParent = wnd->getMDIParent(); - - splash->close(); - + // load in a separate thread to avoid freezing the GUI thread. + struct Loader : Thread { + Loader(SplashWindow& splash) : Thread(), splash(splash) { } + int run() { + load([this](const string& str) { this->splash(str); }, [this](float progress) { this->splash(progress); }); + + splash(Text::fromT(_T(APPNAME))); + + dwt::Application::instance().callAsync([this] { + bindtextdomain(PACKAGE, LOCALEDIR); + textdomain(PACKAGE); + + if(ResourceManager::getInstance()->isRTL()) { + SetProcessDefaultLayout(LAYOUT_RTL); + } + + dwtTexts::init(); + + WinUtil::init(); + + MainWindow* wnd = new MainWindow; + WinUtil::mainWindow = wnd; + //WinUtil::mdiParent = wnd->getMDIParent(); + + this->splash.close(); + }); + return 0; + } + SplashWindow& splash; + } loader { *splash }; + + loader.start(); app.run(); } catch(const std::exception& e) {
_______________________________________________ Mailing list: https://launchpad.net/~linuxdcpp-team Post to : linuxdcpp-team@lists.launchpad.net Unsubscribe : https://launchpad.net/~linuxdcpp-team More help : https://help.launchpad.net/ListHelp