constification: clean up final warning
This explains why we use const_cast<>. We also fix a logic error that crept in here, in which a source might have its state saved twice
This commit is contained in:
parent
0d82703f8e
commit
f8dc6d93ec
@ -2103,7 +2103,7 @@ private:
|
|||||||
int set_state (const XMLNode& node, int version); // not idempotent
|
int set_state (const XMLNode& node, int version); // not idempotent
|
||||||
XMLNode& get_template ();
|
XMLNode& get_template ();
|
||||||
|
|
||||||
void maybe_copy_midifiles (snapshot_t, boost::shared_ptr<Source> src, XMLNode*);
|
bool maybe_copy_midifile (snapshot_t, boost::shared_ptr<Source> src, XMLNode*);
|
||||||
|
|
||||||
/* click track */
|
/* click track */
|
||||||
typedef std::list<Click*> Clicks;
|
typedef std::list<Click*> Clicks;
|
||||||
|
@ -1314,8 +1314,18 @@ Session::state (bool save_template, snapshot_t snapshot_type, bool only_used_ass
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (snapshot_type != NormalSave && fs->within_session ()) {
|
if (snapshot_type != NormalSave && fs->within_session ()) {
|
||||||
#warning CONSTIFICATION maybe fix this
|
/* this copying of MIDI files should not really be occuring within a const scope like
|
||||||
const_cast<Session*>(this)->maybe_copy_midifiles (snapshot_type, siter->second, child);
|
::state(). However the copying is too intertwined with getting the current state of
|
||||||
|
the Source, and so we can't move it to before ::state() is called. If we are not
|
||||||
|
switching to a new snapshot (but are making a snapshot), we want the state from
|
||||||
|
before the copy. If we are switching to a new snapshot, we want the state from after
|
||||||
|
the copy. This makes it almost impossible to tease this apart. So for now (April
|
||||||
|
2022) we use const_cast.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (const_cast<Session*>(this)->maybe_copy_midifile (snapshot_type, siter->second, child)) {
|
||||||
|
continue; /* state already added to child */
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
child->add_child_nocopy (siter->second->get_state());
|
child->add_child_nocopy (siter->second->get_state());
|
||||||
@ -1475,8 +1485,8 @@ Session::state (bool save_template, snapshot_t snapshot_type, bool only_used_ass
|
|||||||
return *node;
|
return *node;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
bool
|
||||||
Session::maybe_copy_midifiles (snapshot_t snapshot_type, boost::shared_ptr<Source> src, XMLNode* child)
|
Session::maybe_copy_midifile (snapshot_t snapshot_type, boost::shared_ptr<Source> src, XMLNode* child)
|
||||||
{
|
{
|
||||||
/* copy MIDI sources to new file
|
/* copy MIDI sources to new file
|
||||||
*
|
*
|
||||||
@ -1495,7 +1505,7 @@ Session::maybe_copy_midifiles (snapshot_t snapshot_type, boost::shared_ptr<Sourc
|
|||||||
boost::shared_ptr<SMFSource> ms;
|
boost::shared_ptr<SMFSource> ms;
|
||||||
|
|
||||||
if ((ms = boost::dynamic_pointer_cast<SMFSource> (src)) == 0) {
|
if ((ms = boost::dynamic_pointer_cast<SMFSource> (src)) == 0) {
|
||||||
return;
|
return false; /* No, it was not a MIDI source */
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string ancestor_name = ms->ancestor_name();
|
const std::string ancestor_name = ms->ancestor_name();
|
||||||
@ -1547,8 +1557,9 @@ Session::maybe_copy_midifiles (snapshot_t snapshot_type, boost::shared_ptr<Sourc
|
|||||||
child->add_child_nocopy (ms->get_state());
|
child->add_child_nocopy (ms->get_state());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
return true; /* Yes, it was a MIDI file */
|
||||||
|
}
|
||||||
|
|
||||||
XMLNode&
|
XMLNode&
|
||||||
Session::get_control_protocol_state () const
|
Session::get_control_protocol_state () const
|
||||||
|
Loading…
Reference in New Issue
Block a user