do not attempt to use scroll view for AU plugin GUIs (fixes crash-on-delete of Cocoa...
authorPaul Davis <paul@linuxaudiosystems.com>
Fri, 3 Jul 2009 21:21:30 +0000 (21:21 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Fri, 3 Jul 2009 21:21:30 +0000 (21:21 +0000)
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@5310 d708f5d6-7413-0410-9779-e7cbd77b26cf

SConstruct
gtk2_ardour/ardour_ui.cc
gtk2_ardour/au_pluginui.h
gtk2_ardour/au_pluginui.mm
gtk2_ardour/plugin_ui.cc
gtk2_ardour/plugin_ui.h
libs/ardour/audio_unit.cc

index 1867a3a25828c2b3a4c5bf6fa237a0641614bbe7..b005447e044995c5ecc26ac4ad87431a098644a1 100644 (file)
@@ -483,18 +483,6 @@ libraries = { }
 
 libraries['core'] = LibraryInfo (CCFLAGS = '-Ilibs')
 
-#libraries['sndfile'] = LibraryInfo()
-#libraries['sndfile'].ParseConfig('pkg-config --cflags --libs sndfile')
-
-libraries['lrdf'] = LibraryInfo()
-libraries['lrdf'].ParseConfig('pkg-config --cflags --libs lrdf')
-
-libraries['raptor'] = LibraryInfo()
-libraries['raptor'].ParseConfig('pkg-config --cflags --libs raptor')
-
-libraries['samplerate'] = LibraryInfo()
-libraries['samplerate'].ParseConfig('pkg-config --cflags --libs samplerate')
-
 conf = env.Configure (custom_tests = { 'CheckPKGExists' : CheckPKGExists } )
 
 if conf.CheckPKGExists ('fftw3f'):
@@ -570,6 +558,15 @@ libraries['xml'].ParseConfig('pkg-config --cflags --libs libxml-2.0')
 libraries['xslt'] = LibraryInfo()
 libraries['xslt'].ParseConfig('pkg-config --cflags --libs libxslt')
 
+libraries['lrdf'] = LibraryInfo()
+libraries['lrdf'].ParseConfig('pkg-config --cflags --libs lrdf')
+
+libraries['raptor'] = LibraryInfo()
+libraries['raptor'].ParseConfig('pkg-config --cflags --libs raptor')
+
+libraries['samplerate'] = LibraryInfo()
+libraries['samplerate'].ParseConfig('pkg-config --cflags --libs samplerate')
+
 libraries['glib2'] = LibraryInfo()
 libraries['glib2'].ParseConfig ('pkg-config --cflags --libs glib-2.0')
 libraries['glib2'].ParseConfig ('pkg-config --cflags --libs gobject-2.0')
index 841d74f0b20ba9e25dbdb181827146f0108bbb6e..726873dffc873b3083e439f27e2bbb6399a0e8bb 100644 (file)
@@ -2408,7 +2408,9 @@ ARDOUR_UI::close_session ()
                return;
        }
 
-       unload_session (true);
+       if (unload_session (true)) {
+               return;
+       }
        
        get_session_parameters (true, false);
 }
index 2f7e5a1f90797d112cd0be5a7a04ebcbf782fe42..481378e41330ee1074271f58d50d70b8085475ee 100644 (file)
@@ -69,7 +69,6 @@ class AUPluginUI : public PlugUIBase, public Gtk::VBox
        /* Cocoa */
 
        NSWindow*           cocoa_window;
-       NSScrollView*       scroll_view;
        NSView*             au_view;
 
        /* Carbon */
index 205364b34348168f357d2517f71b2f693403516d..1d7029365a87b0656a06ca82d49e45f018a0bfb9 100644 (file)
@@ -130,8 +130,12 @@ AUPluginUI::~AUPluginUI ()
                DisposeWindow (carbon_window);
        }
 
-       if (packView && packView != au_view) {
-               [packView release];
+       if (packView) {
+               /* remove whatever we packed into low_box so that GTK doesn't
+                  mess with it.
+               */
+
+               [packView removeFromSuperview];
        }
 }
 
@@ -285,46 +289,12 @@ AUPluginUI::create_cocoa_view ()
                [(AUGenericView *)au_view setShowsExpertParameters:YES];
        }
 
-       NSRect packFrame;
+       packView = au_view;
 
        // Get the size of the new AU View's frame 
+       
+       NSRect packFrame;
        packFrame = [au_view frame];
-
-       packFrame.origin.x = 0;
-       packFrame.origin.y = 0;
-
-       if (packFrame.size.width > 500 || packFrame.size.height > 500) {
-               
-               /* its too big - use a scrollview */
-
-               NSRect frameRect = [[cocoa_window contentView] frame];
-               scroll_view = [[[NSScrollView alloc] initWithFrame:frameRect] autorelease];
-               [scroll_view setDrawsBackground:NO];
-               [scroll_view setHasHorizontalScroller:YES];
-               [scroll_view setHasVerticalScroller:YES];
-
-               packFrame.size = [NSScrollView  frameSizeForContentSize:packFrame.size
-                                   hasHorizontalScroller:[scroll_view hasHorizontalScroller]
-                                   hasVerticalScroller:[scroll_view hasVerticalScroller]
-                                   borderType:[scroll_view borderType]];
-               
-               // Create a new frame with same origin as current
-               // frame but size equal to the size of the new view
-               NSRect newFrame;
-               newFrame.origin = [scroll_view frame].origin;
-               newFrame.size = packFrame.size;
-               
-               // Set the new frame and document views on the scroll view
-               [scroll_view setFrame:newFrame];
-               [scroll_view setDocumentView:au_view];
-               
-               packView = scroll_view;
-
-       } else {
-
-               packView = au_view;
-       }
-
        prefwidth = packFrame.size.width;
        prefheight = packFrame.size.height;
 
@@ -552,7 +522,6 @@ AUPluginUI::parent_cocoa_window ()
        packFrame = [au_view frame];
 
        NSView* view = gdk_quartz_window_get_nsview (low_box.get_window()->gobj());
-       
 
        [view setFrame:packFrame];
        [view addSubview:packView]; 
index 8c32028d71c5789e4c9bfa213fb63e953364e850..0705d22a8b51184a7f88b7ad1035323b2c36c87b 100644 (file)
@@ -322,7 +322,6 @@ PluginUIWindow::plugin_going_away ()
        }
        
        death_connection.disconnect ();
-
        delete_when_idle (this);
 }
 
@@ -361,12 +360,22 @@ PlugUIBase::PlugUIBase (boost::shared_ptr<PluginInsert> pi)
 
        ARDOUR_UI::instance()->set_tip (&focus_button, _("Click to allow the plugin to receive keyboard events that Ardour would normally use as a shortcut"), "");
        ARDOUR_UI::instance()->set_tip (&bypass_button, _("Click to enable/disable this plugin"), "");
+
+       insert->GoingAway.connect (mem_fun (*this, &PlugUIBase::plugin_going_away));
 }
 
 PlugUIBase::~PlugUIBase ()
 {
 }
 
+void
+PlugUIBase::plugin_going_away ()
+{
+       /* drop references to the plugin/insert */
+       insert.reset ();
+       plugin.reset ();
+}
+
 void
 PlugUIBase::redirect_active_changed (Redirect* r, void* src)
 {
index 4c14224a58a8b6d90f0b19b17629c567dc001353..3e027b620ede2c2e253d49cd762091347c5659ec 100644 (file)
@@ -99,6 +99,8 @@ class PlugUIBase : public virtual sigc::trackable
        bool focus_toggled(GdkEventButton*);
        void bypass_toggled();
        void redirect_active_changed (ARDOUR::Redirect* r, void* src);
+
+       void plugin_going_away ();
 };
 
 class GenericPluginUI : public PlugUIBase, public Gtk::VBox 
index 5d9a87a0176b952bee87891dad4340533cdae9ca..6692e90d247b12388547ca70eca64670de08d486 100644 (file)
@@ -799,9 +799,12 @@ AUPlugin::can_do (int32_t in, int32_t& out)
                        }
                }
 
+               if (plugcnt == 1) {
+                       break;
+               }
+
        }
 
-       /* no fit */
        return plugcnt;
 }
 
@@ -1651,7 +1654,9 @@ AUPluginInfo::discover_by_description (PluginInfoList& plugs, CAComponentDescrip
                if (cached_io_configuration (info->unique_id, info->version, cacomp, info->cache, info->name)) {
 
                        /* here we have to map apple's wildcard system to a simple pair
-                          of values.
+                          of values. in ::can_do() we use the whole system, but here
+                          we need a single pair of values. XXX probably means we should
+                          remove any use of these values.
                        */
 
                        info->n_inputs = info->cache.io_configs.front().first;
@@ -1825,7 +1830,8 @@ AUPluginInfo::load_cached_info ()
                        }
 
                        std::string id = prop->value();
-                       
+                       AUPluginCachedInfo cinfo;
+
                        for (XMLNodeConstIterator giter = gchildren.begin(); giter != gchildren.end(); giter++) {
 
                                gchild = *giter;
@@ -1842,12 +1848,14 @@ AUPluginInfo::load_cached_info ()
                                                in = atoi (iprop->value());
                                                out = atoi (iprop->value());
                                                
-                                               AUPluginCachedInfo cinfo;
                                                cinfo.io_configs.push_back (pair<int,int> (in, out));
-                                               add_cached_info (id, cinfo);
                                        }
                                }
                        }
+
+                       if (cinfo.io_configs.size()) {
+                               add_cached_info (id, cinfo);
+                       }
                }
        }