Skip to content

Commit 85027f9

Browse files
committed
Fix crash on startup, it's a race condition in the module progress signal subscribers.
The Splash screen would not unsubscribe from the progress channel, even thought the controls have already been destroyed. The next progress call will run into a crash since the Splash dialog just schedules its deletion (which would trigger the auto-unsubscribe, but it comes too late).
1 parent 91df6a1 commit 85027f9

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

radiant/ui/splash/Splash.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,11 @@ Splash::Splash() :
8787
Show();
8888

8989
// Subscribe to the post-module init event to destroy ourselves
90-
module::GlobalModuleRegistry().signal_allModulesInitialised().connect(
91-
sigc::hide_return(sigc::mem_fun(this, &Splash::Destroy)));
90+
module::GlobalModuleRegistry().signal_allModulesInitialised().connect([this]
91+
{
92+
_moduleProgressConnection.disconnect();
93+
Destroy();
94+
});
9295
}
9396

9497
void Splash::queueDraw()
@@ -127,7 +130,7 @@ Splash& Splash::Instance()
127130
void Splash::OnAppStartup()
128131
{
129132
// Connect the module progress callback
130-
module::GlobalModuleRegistry().signal_moduleInitialisationProgress().connect(
133+
Instance()._moduleProgressConnection = module::GlobalModuleRegistry().signal_moduleInitialisationProgress().connect(
131134
sigc::mem_fun(Instance(), &Splash::setProgressAndText));
132135
}
133136

radiant/ui/splash/Splash.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ class Splash :
2020
wxGauge* _progressBar;
2121
wxImagePanel* _imagePanel;
2222

23+
sigc::connection _moduleProgressConnection;
24+
2325
// Private constructor, creates all the widgets
2426
Splash();
2527

0 commit comments

Comments
 (0)