Cleanup: use an early return to calm some indentation.
[dcpomatic.git] / src / tools / dcpomatic_batch.cc
index a2db604df15ebfae89d92fd66cac4730cfd450cd..b73d0a4184cefd39ad2ecaed34ea50178115df85 100644 (file)
@@ -24,6 +24,7 @@
 #include "wx/full_config_dialog.h"
 #include "wx/job_manager_view.h"
 #include "wx/servers_list_dialog.h"
+#include "wx/wx_ptr.h"
 #include "wx/wx_signal_manager.h"
 #include "wx/wx_util.h"
 #include "lib/compose.hpp"
@@ -268,16 +269,14 @@ private:
                        return true;
                }
 
-               auto d = new wxMessageDialog (
-                       0,
+               auto d = make_wx<wxMessageDialog>(
+                       nullptr,
                        _("There are unfinished jobs; are you sure you want to quit?"),
                        _("Unfinished jobs"),
                        wxYES_NO | wxYES_DEFAULT | wxICON_QUESTION
                        );
 
-               bool const r = d->ShowModal() == wxID_YES;
-               d->Destroy ();
-               return r;
+               return d->ShowModal() == wxID_YES;
        }
 
        void close (wxCloseEvent& ev)
@@ -321,22 +320,21 @@ private:
 
        void help_about ()
        {
-               auto d = new AboutDialog (this);
+               auto d = make_wx<AboutDialog>(this);
                d->ShowModal ();
-               d->Destroy ();
        }
 
        void add_film ()
        {
-               auto c = new wxDirDialog (this, _("Select film to open"), wxStandardPaths::Get().GetDocumentsDir(), wxDEFAULT_DIALOG_STYLE | wxDD_DIR_MUST_EXIST);
+               auto dialog = make_wx<wxDirDialog>(this, _("Select film to open"), wxStandardPaths::Get().GetDocumentsDir(), wxDEFAULT_DIALOG_STYLE | wxDD_DIR_MUST_EXIST);
                if (_last_parent) {
-                       c->SetPath (std_to_wx(_last_parent.get().string()));
+                       dialog->SetPath(std_to_wx(_last_parent.get().string()));
                }
 
                int r;
                while (true) {
-                       r = c->ShowModal ();
-                       if (r == wxID_OK && c->GetPath() == wxStandardPaths::Get().GetDocumentsDir()) {
+                       r = dialog->ShowModal();
+                       if (r == wxID_OK && dialog->GetPath() == wxStandardPaths::Get().GetDocumentsDir()) {
                                error_dialog (this, _("You did not select a folder.  Make sure that you select a folder before clicking Open."));
                        } else {
                                break;
@@ -344,12 +342,10 @@ private:
                }
 
                if (r == wxID_OK) {
-                       start_job (wx_to_std (c->GetPath ()));
+                       start_job(wx_to_std(dialog->GetPath()));
                }
 
-               _last_parent = boost::filesystem::path (wx_to_std (c->GetPath ())).parent_path ();
-
-               c->Destroy ();
+               _last_parent = boost::filesystem::path(wx_to_std(dialog->GetPath())).parent_path();
        }
 
        void config_changed (Config::Property what)