D. Michael McIntyre wrote:
On 02/10/2013 07:37 PM, Ted Felix wrote:

>>  Clearly the patch I submitted should not be used as is.
>
>       Really appreciate the effort, though.  We need the help.  You might
>  be really close, depending on the situation.
Probably won't get anywhere, but I have a minute, and I'm poking around
to see if I see anything.  Will report.
-- D. Michael McIntyre

I think I've got it this time.  I was almost there anyway.  I found a way to add
and remove submaster busses without resorting to copying.

The Studio class already contained an addBuss() function, and now it also
contains a removeBuss() function.

Tim Munro
--- src/base/Studio.h   2013-01-07 13:43:44.000000000 -0800
+++ src/base/Studio.h   2013-02-11 10:41:23.701417112 -0800
@@ -92,6 +92,7 @@
     BussList getBusses();
     Buss *getBussById(BussId id);
     void addBuss(Buss *buss);
+    void removeBuss(BussId id);
 
     // Return an Instrument or a Buss
     PluginContainer *getContainerById(InstrumentId id);

--- src/base/Studio.cpp 2013-01-07 13:43:44.000000000 -0800
+++ src/base/Studio.cpp 2013-02-11 10:03:28.965344322 -0800
@@ -322,6 +322,18 @@
     m_busses.push_back(buss);
 }
 
+void
+Studio::removeBuss(BussId id)
+{
+    for (BussList::iterator i = m_busses.begin(); i != m_busses.end(); ++i) {
+        if ((*i)->getId() == id) {
+            delete *i;
+            m_busses.erase(i);
+            return;
+        }
+    }
+}
+
 PluginContainer *
 Studio::getContainerById(InstrumentId id)
 {

--- src/gui/studio/AudioMixerWindow.cpp 2013-01-07 13:43:39.000000000 -0800
+++ src/gui/studio/AudioMixerWindow.cpp 2013-02-11 10:36:23.129407496 -0800
@@ -130,26 +130,45 @@
     createAction("show_unassigned_faders", SLOT(slotToggleUnassignedFaders()))
         ->setChecked(mixerOptions & MIXER_SHOW_UNASSIGNED_FADERS);
 
-    QAction *action = 0;
+    QAction *ri_action[17];
+    for (int i = 0; i < 17; i++){
+      ri_action[i] = 0;
+    }
 
     for (int i = 1; i <= 16; i *= 2) {
-        action = createAction
+        ri_action[i] = createAction
             (QString("inputs_%1").arg(i), SLOT(slotSetInputCountFromAction()));
-        if (i == int(m_studio->getRecordIns().size()))
-            action->setChecked(true);
+    }
+
+    QAction *sm_action[9];
+    for (int i = 0; i < 9; i++){
+      sm_action[i] = 0;
     }
 
     createAction("submasters_0", SLOT(slotSetSubmasterCountFromAction()));
     
     for (int i = 2; i <= 8; i *= 2) {
-        action = createAction
+        sm_action[i] = createAction
             (QString("submasters_%1").arg(i), 
SLOT(slotSetSubmasterCountFromAction()));
-        
-        if (i == int(m_studio->getBusses().size()) - 1)
-            action->setChecked(true);
     }
 
     createGUI("mixer.rc");
+
+    // The action->setChecked() stuff must be done after createGUI("mixer.rc"),
+    // if the initial "Number of stereo Inputs" and "Number of Submasters"
+    // menus are to reflect reality.
+    for (int i = 1; i <= 16; i *= 2) {
+        if (i == int(m_studio->getRecordIns().size())) {
+            ri_action[i]->setChecked(true);
+        }
+    }
+    // "submasters_0" is checked by default in data/rc/mixer.rc
+    for (int i = 2; i <= 8; i *= 2) {
+        if (i == int(m_studio->getBusses().size()) - 1) {
+            sm_action[i]->setChecked(true);
+        }
+    }
+
     setRewFFwdToAutoRepeat();
 
     // We must populate AFTER the actions are created, or else all the
@@ -692,6 +711,8 @@
 //            rec.m_plugins[index]->setPaletteBackgroundColor(pluginBgColour);
         }
     }
+    // Force an immediate update of button colors.
+    populate();
 }
 
 void
@@ -1411,25 +1432,32 @@
 
         // offset by 1 generally to take into account the fact that
         // the first buss in the studio is the master, not a submaster
-
         if (count + 1 == current)
             return ;
 
-        BussList dups;
-        for (int i = 0; i < count; ++i) {
-            if (i + 1 < int(busses.size())) {
-                dups.push_back(new Buss(*busses[i + 1]));
-            } else {
-                dups.push_back(new Buss(i + 1));
+        if (count + 1 < current) {
+
+            BussList::iterator it = busses.end();
+            it--;  // Now this actually points to something
+
+            while (count + 1 < current--) {
+                m_studio->removeBuss((*it--)->getId());
             }
-        }
 
-        m_studio->clearBusses();
+        } else {
+
+            BussList::iterator it = busses.end();
+            it--;
+            unsigned int lastId = (*it)->getId();
+
+            while (count + 1 > current++) {
+                m_studio->addBuss(new Buss(++lastId));
+            }
 
-        for (BussList::iterator i = dups.begin();
-                i != dups.end(); ++i) {
-            m_studio->addBuss(*i);
         }
+//      busses = m_studio->getBusses();
+//      for (BussList::iterator it = busses.begin(); it != busses.end(); it++)
+//          std::cout << "******* BussId:" << (*it)->getId() << std::endl;
     }
 
     m_document->initialiseStudio();
------------------------------------------------------------------------------
Free Next-Gen Firewall Hardware Offer
Buy your Sophos next-gen firewall before the end March 2013 
and get the hardware for free! Learn more.
http://p.sf.net/sfu/sophos-d2d-feb
_______________________________________________
Rosegarden-devel mailing list
[email protected] - use the link below to unsubscribe
https://lists.sourceforge.net/lists/listinfo/rosegarden-devel

Reply via email to