Fix send copying by paste and drag n drop.
authorCarl Hetherington <carl@carlh.net>
Sat, 14 Feb 2009 17:28:01 +0000 (17:28 +0000)
committerCarl Hetherington <carl@carlh.net>
Sat, 14 Feb 2009 17:28:01 +0000 (17:28 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@4550 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/processor_box.cc
libs/ardour/ardour/send.h
libs/ardour/io.cc
libs/ardour/send.cc

index 567dc2985fbd67073ffe65f5572641c57c74479a..34e4f27ae000deebebf975c1eae0de5b872b45e9 100644 (file)
@@ -964,8 +964,16 @@ ProcessorBox::paste_processor_state (const XMLNode& node)
 
        for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
                cerr << "try using " << (*niter)->name() << endl;
+               XMLProperty const * type = (*niter)->property ("type");
+               assert (type);
                try {
-                       copies.push_back (boost::shared_ptr<Processor> (new PluginInsert (_session, **niter)));
+                       if (type->value() == "send") {
+                               XMLNode n (**niter);
+                               Send::make_unique (n, _session);
+                               copies.push_back (boost::shared_ptr<Processor> (new Send (_session, n)));
+                       } else {
+                               copies.push_back (boost::shared_ptr<Processor> (new PluginInsert (_session, **niter)));
+                       }
                }
                catch (...) {
                        cerr << "plugin insert constructor failed\n";
index 497027866b77128c0ba22feef82e130ee9914043..b65675dc2ca5050c979053792792df3b7f611bdc 100644 (file)
@@ -62,6 +62,7 @@ class Send : public IOProcessor
        bool configure_io (ChanCount in, ChanCount out);
 
        static uint32_t how_many_sends();
+       static void make_unique (XMLNode &, Session &);
 
   private:
        bool      _metering;
index 2a502361cb1bec80e652b6778ea21b78360a695c..43a61061d9765b595c3e1eaf77d02134ca5dcb10 100644 (file)
@@ -1340,7 +1340,7 @@ IO::set_state (const XMLNode& node)
        if ((prop = node.property ("name")) != 0) {
                _name = prop->value();
                /* used to set panner name with this, but no more */
-       } 
+       }
 
        if ((prop = node.property ("id")) != 0) {
                _id = prop->value ();
index bb5a4245752d2fcba5886d39782ce5468abdc6d5..252ca691befb27026f49a7b40fdd4d2a13237fdd 100644 (file)
@@ -43,7 +43,7 @@ Send::Send (Session& s, Placement p)
 }
 
 Send::Send (Session& s, const XMLNode& node)
-       : IOProcessor (s,  "send", PreFader)
+       : IOProcessor (s, "send", PreFader)
 {
        _metering = false;
 
@@ -61,37 +61,31 @@ Send::Send (const Send& other)
 
        expected_inputs.set (DataType::AUDIO, 0);
 
-#ifdef THIS_NEEDS_FIXING_FOR_V3
-
        /* set up the same outputs, and connect them to the same places */
 
-       _io->no_panner_reset = true;
+       _io->defer_pan_reset ();
 
-       for (uint32_t i = 0; i < other.n_outputs (); ++i) {
-               add_output_port ("", 0);
-               Port* p = other.output (i);
+       for (uint32_t i = 0; i < other._io->n_outputs().get (_io->default_type()); ++i) {
+               _io->add_output_port ("", 0);
+               Port* p = other._io->output (i);
                if (p) {
                        /* this is what the other send's output is connected to */
-                       const char **connections = p->get_connections ();
-                       if (connections) {
-                               for (uint32_t c = 0; connections[c]; ++c) {
-                                       connect_output (output (i), connections [c], 0);
-                               }
+                       std::vector<std::string> connections;
+                       p->get_connections (connections);
+                       for (uint32_t j = 0; j < connections.size(); ++j) {
+                               _io->connect_output (_io->output (i), connections[j], 0);
                        }
                }
        }
        
        /* setup panner */
 
-       _io->no_panner_reset = false;
-
-       /* copy state */
+       _io->allow_pan_reset ();
 
-       XMLNode& other_state (const_cast<Send*>(&other)->_panner->get_state());
-       _panner->set_state (other_state);
+       XMLNode& other_state (other._io->panner().get_state ());
+       _io->panner().set_state (other_state);
        
        delete &other_state;
-#endif
 
        ProcessorCreated (this); /* EMIT SIGNAL */
 }
@@ -265,3 +259,26 @@ Send::expect_inputs (const ChanCount& expected)
                _io->reset_panner ();
        }
 }
+
+/** Set up the XML description of a send so that its name is unique.
+ *  @param state XML send state.
+ *  @param session Session.
+ */
+void
+Send::make_unique (XMLNode &state, Session &session)
+{
+       uint32_t const bitslot = session.next_send_id() + 1;
+
+       char buf[32];
+       snprintf (buf, sizeof (buf), "%" PRIu32, bitslot);
+       state.property("bitslot")->set_value (buf);
+
+       std::string const name = string_compose (_("send %1"), bitslot);
+       
+       state.property("name")->set_value (name);
+
+       XMLNode* io = state.child ("IO");
+       if (io) {
+               io->property("name")->set_value (name);
+       }
+}