Fix shared_ptr for Film.
[dcpomatic.git] / src / tools / dvdomatic.cc
index 9ff2c1ddc4016f6768d1bd1af142188e25ee6bbc..b5c81da07f2ba8cbcb42318532704264c7f45884 100644 (file)
@@ -31,6 +31,7 @@
 #include "wx/wx_util.h"
 #include "wx/new_film_dialog.h"
 #include "wx/properties_dialog.h"
+#include "wx/wx_ui_signaller.h"
 #include "lib/film.h"
 #include "lib/format.h"
 #include "lib/config.h"
 #include "lib/util.h"
 #include "lib/scaler.h"
 #include "lib/exceptions.h"
+#include "lib/version.h"
+#include "lib/ui_signaller.h"
 
-using namespace std;
-using namespace boost;
+using std::string;
+using std::stringstream;
+using std::map;
+using std::make_pair;
+using boost::shared_ptr;
 
 static FilmEditor* film_editor = 0;
 static FilmViewer* film_viewer = 0;
 
-static Film* film = 0;
+static shared_ptr<Film> film;
 
 static void set_menu_sensitivity ();
 
@@ -92,8 +98,7 @@ maybe_save_then_delete_film ()
                }
        }
        
-       delete film;
-       film = 0;
+       film.reset ();
 }
 
 enum Sensitivity {
@@ -226,7 +231,7 @@ public:
                film_editor->setup_visibility ();
                film_viewer->setup_visibility ();
                
-               film_editor->FileChanged.connect (sigc::mem_fun (*this, &Frame::file_changed));
+               film_editor->FileChanged.connect (bind (&Frame::file_changed, this, _1));
                if (film) {
                        file_changed (film->directory ());
                } else {
@@ -261,11 +266,11 @@ public:
                
                if (r == wxID_OK) {
                        maybe_save_then_delete_film ();
-                       film = new Film (d->get_path (), false);
+                       film.reset (new Film (d->get_path (), false));
 #if BOOST_FILESYSTEM_VERSION == 3              
-                       film->set_name (filesystem::path (d->get_path()).filename().generic_string());
+                       film->set_name (boost::filesystem::path (d->get_path()).filename().generic_string());
 #else          
-                       film->set_name (filesystem::path (d->get_path()).filename());
+                       film->set_name (boost::filesystem::path (d->get_path()).filename());
 #endif
                        set_film ();
                }
@@ -281,7 +286,7 @@ public:
                
                if (r == wxID_OK) {
                        maybe_save_then_delete_film ();
-                       film = new Film (wx_to_std (c->GetPath ()));
+                       film.reset (new Film (wx_to_std (c->GetPath ())));
                        set_film ();
                }
        }
@@ -350,7 +355,7 @@ public:
        {
                wxAboutDialogInfo info;
                info.SetName (_("DVD-o-matic"));
-               info.SetVersion (wxT (DVDOMATIC_VERSION));
+               info.SetVersion (std_to_wx (String::compose ("version %1 git %2", dvdomatic_version, dvdomatic_git_commit)));
                info.SetDescription (_("Free, open-source DCP generation from almost anything."));
                info.SetCopyright (_("(C) Carl Hetherington, Terrence Meiczinger, Paul Davis, Ole Laursen"));
                wxArrayString authors;
@@ -373,15 +378,24 @@ class App : public wxApp
                dvdomatic_setup ();
 
                if (argc == 2 && boost::filesystem::is_directory (wx_to_std (argv[1]))) {
-                       film = new Film (wx_to_std (argv[1]));
+                       film.reset (new Film (wx_to_std (argv[1])));
                }
 
                Frame* f = new Frame (_("DVD-o-matic"));
                SetTopWindow (f);
                f->Maximize ();
                f->Show ();
+
+               ui_signaller = new wxUISignaller (this);
+               this->Connect (-1, wxEVT_IDLE, wxIdleEventHandler (App::idle));
+
                return true;
        }
+
+       void idle (wxIdleEvent &)
+       {
+               ui_signaller->ui_idle ();
+       }
 };
 
 IMPLEMENT_APP (App)