push2: fix up issues with object lifetimes and signals during shutdown
authorPaul Davis <paul@linuxaudiosystems.com>
Tue, 12 Jul 2016 11:46:30 +0000 (07:46 -0400)
committerPaul Davis <paul@linuxaudiosystems.com>
Tue, 27 Sep 2016 19:59:31 +0000 (14:59 -0500)
libs/surfaces/push2/layout.h
libs/surfaces/push2/mix.cc
libs/surfaces/push2/push2.cc
libs/surfaces/push2/track_mix.cc
libs/surfaces/push2/wscript

index fcc0b7a47973d8dd6bbf7ddad2265e33273d519a..30e52da5a837174e65f560c5873eb2c5f7150800 100644 (file)
@@ -21,6 +21,8 @@
 
 #include <stdint.h>
 
+#include <sigc++/trackable.h>
+
 #include <cairomm/refptr.h>
 
 namespace ARDOUR {
@@ -35,7 +37,7 @@ namespace ArdourSurface {
 
 class Push2;
 
-class Push2Layout
+class Push2Layout : public sigc::trackable
 {
   public:
        Push2Layout (Push2& p, ARDOUR::Session& s);
index 2d7c9b7781ec6e82accf31cea7533e395d2da4b4..4efc739955528762b759437e6b369ac5732ab7f2 100644 (file)
@@ -43,6 +43,8 @@
 
 #include "canvas/colors.h"
 
+#include "gtkmm2ext/gui_thread.h"
+
 #include "mix.h"
 #include "knob.h"
 #include "push2.h"
@@ -111,8 +113,8 @@ MixLayout::MixLayout (Push2& p, Session& s, Cairo::RefPtr<Cairo::Context> contex
 
        mode_button = p2.button_by_id (Push2::Upper1);
 
-       session.RouteAdded.connect (session_connections, MISSING_INVALIDATOR, boost::bind (&MixLayout::stripables_added, this), &p2);
-       session.vca_manager().VCAAdded.connect (session_connections, MISSING_INVALIDATOR, boost::bind (&MixLayout::stripables_added, this), &p2);
+       session.RouteAdded.connect (session_connections, invalidator(*this), boost::bind (&MixLayout::stripables_added, this), &p2);
+       session.vca_manager().VCAAdded.connect (session_connections, invalidator (*this), boost::bind (&MixLayout::stripables_added, this), &p2);
 }
 
 MixLayout::~MixLayout ()
@@ -515,8 +517,8 @@ MixLayout::switch_bank (uint32_t base)
 
                /* stripable goes away? refill the bank, starting at the same point */
 
-               stripable[n]->DropReferences.connect (stripable_connections, MISSING_INVALIDATOR, boost::bind (&MixLayout::switch_bank, this, bank_start), &p2);
-               stripable[n]->presentation_info().PropertyChanged.connect (stripable_connections, MISSING_INVALIDATOR, boost::bind (&MixLayout::stripable_property_change, this, _1, n), &p2);
+               stripable[n]->DropReferences.connect (stripable_connections, invalidator (*this), boost::bind (&MixLayout::switch_bank, this, bank_start), &p2);
+               stripable[n]->presentation_info().PropertyChanged.connect (stripable_connections, invalidator (*this), boost::bind (&MixLayout::stripable_property_change, this, _1, n), &p2);
 
                Push2::Button* b;
 
index 412fc3c51beb7e284042c5da9656cecec97ff0e2..2f485357465dacdfc03d917466a8ef01fb7c212c 100644 (file)
@@ -40,6 +40,7 @@
 #include "ardour/session.h"
 #include "ardour/tempo.h"
 
+#include "gtkmm2ext/gui_thread.h"
 #include "gtkmm2ext/rgb_macros.h"
 
 #include "canvas/colors.h"
@@ -141,8 +142,6 @@ Push2::Push2 (ARDOUR::Session& s)
        , octave_shift (0)
        , percussion (false)
 {
-       cerr << "new push2 @ " << this << "\n";
-
        context = Cairo::Context::create (frame_buffer);
 
        build_maps ();
@@ -176,15 +175,16 @@ Push2::Push2 (ARDOUR::Session& s)
 
 Push2::~Push2 ()
 {
-       cerr << "push2 deleted\n";
        stop ();
+
+       delete track_mix_layout;
+       delete mix_layout;
+       delete scale_layout;
 }
 
 void
 Push2::port_registration_handler ()
 {
-       cerr << "preg for " << this << endl;
-
        if (!_async_in && !_async_out) {
                /* ports not registered yet */
                return;
index e1165ee9cf69988a33dcf750b3becf47ee11db1b..dac4873e2c1289790a38277ed5a1512b1b1c9d5f 100644 (file)
@@ -40,6 +40,7 @@
 #include "ardour/session.h"
 #include "ardour/tempo.h"
 
+#include "gtkmm2ext/gui_thread.h"
 #include "gtkmm2ext/rgb_macros.h"
 
 #include "knob.h"
@@ -66,42 +67,50 @@ TrackMixLayout::TrackMixLayout (Push2& p, Session& s, Cairo::RefPtr<Cairo::Conte
                upper_layout[n] = Pango::Layout::create (context);
                upper_layout[n]->set_font_description (fd2);
 
+               lower_layout[n] = Pango::Layout::create (context);
+               lower_layout[n]->set_font_description (fd2);
+
                switch (n) {
                case 0:
                        upper_layout[n]->set_text (_("TRACK VOLUME"));
+                       lower_layout[n]->set_text (_("MUTE"));
                        break;
                case 1:
                        upper_layout[n]->set_text (_("TRACK PAN"));
+                       lower_layout[n]->set_text (_("SOLO"));
                        break;
                case 2:
                        upper_layout[n]->set_text (_("TRACK WIDTH"));
+                       lower_layout[n]->set_text (_("REC-ENABLE"));
                        break;
                case 3:
                        upper_layout[n]->set_text (_("TRACK TRIM"));
+                       lower_layout[n]->set_text (_("IN"));
                        break;
                case 4:
                        upper_layout[n]->set_text (_(""));
+                       lower_layout[n]->set_text (_("DISK"));
                        break;
                case 5:
                        upper_layout[n]->set_text (_(""));
+                       lower_layout[n]->set_text (_("SOLO ISO"));
                        break;
                case 6:
                        upper_layout[n]->set_text (_(""));
+                       lower_layout[n]->set_text (_("SOLO LOCK"));
                        break;
                case 7:
                        upper_layout[n]->set_text (_(""));
+                       lower_layout[n]->set_text (_(""));
                        break;
                }
 
-               lower_layout[n] = Pango::Layout::create (context);
-               lower_layout[n]->set_font_description (fd2);
-
                knobs[n] = new Push2Knob (p2, context);
                knobs[n]->set_position (60 + (120*n), 95);
                knobs[n]->set_radius (25);
        }
 
-       ControlProtocol::StripableSelectionChanged.connect (selection_connection, MISSING_INVALIDATOR, boost::bind (&TrackMixLayout::selection_changed, this), &p2);
+       ControlProtocol::StripableSelectionChanged.connect (selection_connection, invalidator (*this), boost::bind (&TrackMixLayout::selection_changed, this), &p2);
 }
 
 TrackMixLayout::~TrackMixLayout ()
@@ -147,17 +156,23 @@ TrackMixLayout::redraw (Cairo::RefPtr<Cairo::Context> context, bool force) const
 
        for (int n = 0; n < 8; ++n) {
 
-               if (upper_layout[n]->get_text().empty()) {
-                       continue;
-               }
+               if (!upper_layout[n]->get_text().empty()) {
+
+                       /* Draw highlight box */
 
-               /* Draw highlight box */
+                       uint32_t color = p2.get_color (Push2::ParameterName);
+                       set_source_rgb (context, color);
 
-               uint32_t color = p2.get_color (Push2::ParameterName);
-               set_source_rgb (context, color);
-               context->move_to (10 + (n*120), 2);
-               upper_layout[n]->update_from_cairo_context (context);
-               upper_layout[n]->show_in_cairo_context (context);
+                       context->move_to (10 + (n*120), 2);
+                       upper_layout[n]->update_from_cairo_context (context);
+                       upper_layout[n]->show_in_cairo_context (context);
+               }
+
+               if (!lower_layout[n]->get_text().empty()) {
+                       context->move_to (10 + (n*120), 140);
+                       lower_layout[n]->update_from_cairo_context (context);
+                       lower_layout[n]->show_in_cairo_context (context);
+               }
        }
 
        context->move_to (0, 22.5);
@@ -191,10 +206,10 @@ TrackMixLayout::set_stripable (boost::shared_ptr<Stripable> s)
 
        if (stripable) {
 
-               stripable->DropReferences.connect (stripable_connections, MISSING_INVALIDATOR, boost::bind (&TrackMixLayout::drop_stripable, this), &p2);
+               stripable->DropReferences.connect (stripable_connections, invalidator (*this), boost::bind (&TrackMixLayout::drop_stripable, this), &p2);
 
-               stripable->PropertyChanged.connect (stripable_connections, MISSING_INVALIDATOR, boost::bind (&TrackMixLayout::stripable_property_change, this, _1), &p2);
-               stripable->presentation_info().PropertyChanged.connect (stripable_connections, MISSING_INVALIDATOR, boost::bind (&TrackMixLayout::stripable_property_change, this, _1), &p2);
+               stripable->PropertyChanged.connect (stripable_connections, invalidator (*this), boost::bind (&TrackMixLayout::stripable_property_change, this, _1), &p2);
+               stripable->presentation_info().PropertyChanged.connect (stripable_connections, invalidator (*this), boost::bind (&TrackMixLayout::stripable_property_change, this, _1), &p2);
 
                knobs[0]->set_controllable (stripable->gain_control());
                knobs[1]->set_controllable (stripable->pan_azimuth_control());
index 147b2e3aa2977b9d7e7604a3eeddf32db084520e..0f1b1c3b7dde9ea1738b40c59bf3bcaeb8be00ab 100644 (file)
@@ -42,7 +42,7 @@ def build(bld):
     obj.includes     = [ '.', './push2']
     obj.name         = 'libardour_push2'
     obj.target       = 'ardour_push2'
-    obj.uselib       = 'CAIROMM PANGOMM USB GTKMM'
+    obj.uselib       = 'CAIROMM PANGOMM USB GTKMM SIGCPP'
     obj.use          = 'libardour libardour_cp libgtkmm2ext libpbd libevoral libcanvas libtimecode'
     obj.install_path = os.path.join(bld.env['LIBDIR'], 'surfaces')