From 293f82daa07bbc357940e5dd214f7c534bab0a86 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 25 Apr 2023 11:03:54 +0200 Subject: Don't use wx_ptr for the splash screen. Using wx_ptr in the wxApp object seems bad because in ~App wxWidgets deletes all top-level windows in `DeleteAllTLWs` so if ~wx_ptr then tries to destroy them we get a use-after-free. --- src/tools/dcpomatic.cc | 9 +++++---- src/tools/dcpomatic_editor.cc | 2 +- src/tools/dcpomatic_kdm.cc | 2 +- src/tools/dcpomatic_player.cc | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) (limited to 'src/tools') diff --git a/src/tools/dcpomatic.cc b/src/tools/dcpomatic.cc index a7b3af8bc..3d944e780 100644 --- a/src/tools/dcpomatic.cc +++ b/src/tools/dcpomatic.cc @@ -1709,7 +1709,7 @@ private: } catch (exception& e) { - _splash.reset(); + close_splash(); error_dialog (nullptr, wxString::Format ("DCP-o-matic could not start."), std_to_wx(e.what())); } @@ -1821,7 +1821,8 @@ private: void close_splash () { - _splash.reset(); + _splash->Destroy(); + _splash = nullptr; } void config_failed_to_load (Config::LoadFailure what) @@ -1839,7 +1840,7 @@ private: /* Destroy the splash screen here, as otherwise bad things seem to happen (for reasons unknown) when we open our recreate dialog, close it, *then* try to Destroy the splash (the Destroy fails). */ - _splash.reset(); + close_splash(); auto config = Config::instance(); switch (reason) { @@ -1908,7 +1909,7 @@ private: } DOMFrame* _frame = nullptr; - wx_ptr _splash; + wxSplashScreen* _splash; shared_ptr _timer; string _film_to_load; string _film_to_create; diff --git a/src/tools/dcpomatic_editor.cc b/src/tools/dcpomatic_editor.cc index 663eb8e3b..a61a17ce4 100644 --- a/src/tools/dcpomatic_editor.cc +++ b/src/tools/dcpomatic_editor.cc @@ -428,7 +428,7 @@ private: bool OnInit () override { - wx_ptr splash; + wxSplashScreen* splash; try { wxInitAllImageHandlers (); diff --git a/src/tools/dcpomatic_kdm.cc b/src/tools/dcpomatic_kdm.cc index 2e28b548a..e2993f9f2 100644 --- a/src/tools/dcpomatic_kdm.cc +++ b/src/tools/dcpomatic_kdm.cc @@ -798,7 +798,7 @@ private: bool OnInit () override { - wx_ptr splash; + wxSplashScreen* splash; try { wxInitAllImageHandlers (); diff --git a/src/tools/dcpomatic_player.cc b/src/tools/dcpomatic_player.cc index 5ce02b1ea..ab018c44b 100644 --- a/src/tools/dcpomatic_player.cc +++ b/src/tools/dcpomatic_player.cc @@ -1171,7 +1171,7 @@ private: bool OnInit () override { - wx_ptr splash; + wxSplashScreen* splash; try { wxInitAllImageHandlers (); -- cgit v1.2.3