X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fwx%2Fwx_util.cc;h=e600b63c89c4506e4b161b3b1f5a64617df1a8e8;hb=963c7649da903b87637975e8c2d634da887d3109;hp=1f2afb4f548693ac9be99ae399b01cb881dbfe43;hpb=5800e1f2abecb709cbdc1408d1328f29cdbcb370;p=dcpomatic.git diff --git a/src/wx/wx_util.cc b/src/wx/wx_util.cc index 1f2afb4f5..e600b63c8 100644 --- a/src/wx/wx_util.cc +++ b/src/wx/wx_util.cc @@ -29,12 +29,12 @@ #include "password_entry.h" #include "region_subtag_widget.h" #include "static_text.h" +#include "wx_ptr.h" #include "wx_util.h" #include "lib/config.h" #include "lib/cross.h" #include "lib/job.h" #include "lib/job_manager.h" -#include "lib/scope_guard.h" #include "lib/util.h" #include "lib/version.h" #include @@ -161,8 +161,7 @@ add_label_to_sizer (wxGridBagSizer* s, wxStaticText* t, bool, wxGBPosition pos, void error_dialog (wxWindow* parent, wxString m, optional e) { - auto d = new wxMessageDialog (parent, m, _("DCP-o-matic"), wxOK | wxICON_ERROR); - ScopeGuard sg = [d]() { d->Destroy(); }; + auto d = make_wx(parent, m, _("DCP-o-matic"), wxOK | wxICON_ERROR); if (e) { wxString em = *e; em[0] = wxToupper (em[0]); @@ -179,8 +178,7 @@ error_dialog (wxWindow* parent, wxString m, optional e) void message_dialog (wxWindow* parent, wxString m) { - auto d = new wxMessageDialog (parent, m, _("DCP-o-matic"), wxOK | wxICON_INFORMATION); - ScopeGuard sg = [d]() { d->Destroy(); }; + auto d = make_wx(parent, m, _("DCP-o-matic"), wxOK | wxICON_INFORMATION); d->ShowModal (); } @@ -189,8 +187,7 @@ message_dialog (wxWindow* parent, wxString m) bool confirm_dialog (wxWindow* parent, wxString m) { - auto d = new wxMessageDialog (parent, m, _("DCP-o-matic"), wxYES_NO | wxICON_QUESTION); - ScopeGuard sg = [d]() { d->Destroy(); }; + auto d = make_wx(parent, m, _("DCP-o-matic"), wxYES_NO | wxICON_QUESTION); return d->ShowModal() == wxID_YES; } @@ -540,10 +537,11 @@ setup_audio_channels_choice (wxChoice* choice, int minimum) } -wxSplashScreen * +wx_ptr maybe_show_splash () { - wxSplashScreen* splash = nullptr; + wx_ptr splash; + try { wxBitmap bitmap; if (bitmap.LoadFile(bitmap_path("splash.png"), wxBITMAP_TYPE_PNG)) { @@ -557,9 +555,9 @@ maybe_show_splash () } #ifdef DCPOMATIC_WINDOWS /* Having wxSTAY_ON_TOP means error dialogues hide behind the splash screen on Windows, no matter what I try */ - splash = new wxSplashScreen (bitmap, wxSPLASH_CENTRE_ON_SCREEN | wxSPLASH_NO_TIMEOUT, 0, 0, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_SIMPLE | wxFRAME_NO_TASKBAR); + splash.reset(bitmap, wxSPLASH_CENTRE_ON_SCREEN | wxSPLASH_NO_TIMEOUT, 0, nullptr, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_SIMPLE | wxFRAME_NO_TASKBAR); #else - splash = new wxSplashScreen (bitmap, wxSPLASH_CENTRE_ON_SCREEN | wxSPLASH_NO_TIMEOUT, 0, 0, -1); + splash.reset(bitmap, wxSPLASH_CENTRE_ON_SCREEN | wxSPLASH_NO_TIMEOUT, 0, nullptr, -1); #endif wxYield (); }