summaryrefslogtreecommitdiff
path: root/src/wx/wx_util.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2023-01-14 01:23:06 +0100
committerCarl Hetherington <cth@carlh.net>2023-01-14 01:23:06 +0100
commit5800e1f2abecb709cbdc1408d1328f29cdbcb370 (patch)
treec31c5a9bdb559855e22973ff8ccfb8b68db37891 /src/wx/wx_util.cc
parentabcd6c9182507e6336a1839661dac856d5bea553 (diff)
Use ScopeGuard more.
Diffstat (limited to 'src/wx/wx_util.cc')
-rw-r--r--src/wx/wx_util.cc10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/wx/wx_util.cc b/src/wx/wx_util.cc
index 933d303d1..1f2afb4f5 100644
--- a/src/wx/wx_util.cc
+++ b/src/wx/wx_util.cc
@@ -34,6 +34,7 @@
#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 <dcp/locale_convert.h>
@@ -161,13 +162,13 @@ void
error_dialog (wxWindow* parent, wxString m, optional<wxString> e)
{
auto d = new wxMessageDialog (parent, m, _("DCP-o-matic"), wxOK | wxICON_ERROR);
+ ScopeGuard sg = [d]() { d->Destroy(); };
if (e) {
wxString em = *e;
em[0] = wxToupper (em[0]);
d->SetExtendedMessage (em);
}
d->ShowModal ();
- d->Destroy ();
}
@@ -179,8 +180,8 @@ void
message_dialog (wxWindow* parent, wxString m)
{
auto d = new wxMessageDialog (parent, m, _("DCP-o-matic"), wxOK | wxICON_INFORMATION);
+ ScopeGuard sg = [d]() { d->Destroy(); };
d->ShowModal ();
- d->Destroy ();
}
@@ -189,9 +190,8 @@ bool
confirm_dialog (wxWindow* parent, wxString m)
{
auto d = new wxMessageDialog (parent, m, _("DCP-o-matic"), wxYES_NO | wxICON_QUESTION);
- int const r = d->ShowModal ();
- d->Destroy ();
- return r == wxID_YES;
+ ScopeGuard sg = [d]() { d->Destroy(); };
+ return d->ShowModal() == wxID_YES;
}