Use PBD::string_to functions in VideoUtils::video_query_info
[ardour.git] / libs / surfaces / push2 / push2.cc
index 9f1290ec094deeb0e30392310d55c9947d7509e9..30b521686cfdc80bb21cfe1f4a41c35ee580b1f7 100644 (file)
@@ -17,6 +17,7 @@
 */
 
 #include <stdlib.h>
+#include <pthread.h>
 
 #include "pbd/compose.h"
 #include "pbd/convert.h"
@@ -39,6 +40,7 @@
 #include "ardour/midi_port.h"
 #include "ardour/session.h"
 #include "ardour/tempo.h"
+#include "ardour/types_convert.h"
 
 #include "gtkmm2ext/gui_thread.h"
 #include "gtkmm2ext/rgb_macros.h"
@@ -133,9 +135,14 @@ Push2::Push2 (ARDOUR::Session& s)
 
 Push2::~Push2 ()
 {
+       DEBUG_TRACE (DEBUG::Push2, "push2 control surface object being destroyed\n");
+
+       /* do this before stopping the event loop, so that we don't get any notifications */
        selection_connection.disconnect ();
+       port_reg_connection.disconnect ();
+       port_connection.disconnect ();
 
-       stop_event_loop (); /* this will call stop_using_device () in Quit request handler */
+       stop_using_device ();
        device_release ();
        ports_release ();
 
@@ -150,8 +157,13 @@ Push2::~Push2 ()
        scale_layout = 0;
        delete splash_layout;
        splash_layout = 0;
+       delete track_mix_layout;
+       track_mix_layout = 0;
+
+       stop_event_loop ();
 }
 
+
 void
 Push2::run_event_loop ()
 {
@@ -983,10 +995,10 @@ Push2::get_state()
        child->add_child_nocopy (_async_out->get_state());
        node.add_child_nocopy (*child);
 
-       node.add_property (X_("root"), to_string (_scale_root, std::dec));
-       node.add_property (X_("root_octave"), to_string (_root_octave, std::dec));
-       node.add_property (X_("in_key"), _in_key ? X_("yes") : X_("no"));
-       node.add_property (X_("mode"), enum_2_string (_mode));
+       node.set_property (X_("root"), _scale_root);
+       node.set_property (X_("root-octave"), _root_octave);
+       node.set_property (X_("in-key"), _in_key);
+       node.set_property (X_("mode"), _mode);
 
        return node;
 }
@@ -1018,23 +1030,10 @@ Push2::set_state (const XMLNode & node, int version)
                }
        }
 
-       XMLProperty const* prop;
-
-       if ((prop = node.property (X_("root"))) != 0) {
-               _scale_root = atoi (prop->value());
-       }
-
-       if ((prop = node.property (X_("root_octave"))) != 0) {
-               _root_octave = atoi (prop->value());
-       }
-
-       if ((prop = node.property (X_("in_key"))) != 0) {
-               _in_key = string_is_affirmative (prop->value());
-       }
-
-       if ((prop = node.property (X_("mode"))) != 0) {
-               _mode = (MusicalMode::Type) string_2_enum (prop->value(), _mode);
-       }
+       node.get_property (X_("root"), _scale_root);
+       node.get_property (X_("root-octave"), _root_octave);
+       node.get_property (X_("in-key"), _in_key);
+       node.get_property (X_("mode"), _mode);
 
        return retval;
 }