Skip to content
12 changes: 9 additions & 3 deletions include/Track.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ class LMMS_EXPORT Track : public Model, public JournallingObject
void saveSettings( QDomDocument & doc, QDomElement & element ) override;
void loadSettings( const QDomElement & element ) override;

void setSimpleSerializing()
void setPresetMode(bool presetMode = true)
{
m_simpleSerializingMode = true;
m_presetMode = presetMode;
}

// -- for usage by Clip only ---------------
Expand Down Expand Up @@ -209,6 +209,12 @@ public slots:

void toggleSolo();

protected:
bool isPresetMode() const
{
return m_presetMode;
}

private:
TrackContainer* m_trackContainer;
Type m_type;
Expand All @@ -222,7 +228,7 @@ public slots:
BoolModel m_soloModel;
bool m_mutedBeforeSolo;

bool m_simpleSerializingMode;
bool m_presetMode;

clipVector m_clips;

Expand Down
14 changes: 8 additions & 6 deletions src/core/Track.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Track::Track( Type type, TrackContainer * tc ) :
m_name(), /*!< The track's name */
m_mutedModel( false, this, tr( "Mute" ) ), /*!< For controlling track muting */
m_soloModel( false, this, tr( "Solo" ) ), /*!< For controlling track soloing */
m_simpleSerializingMode( false ),
m_presetMode( false ),
m_clips() /*!< The clips (segments) */
{
m_trackContainer->addTrack( this );
Expand Down Expand Up @@ -191,7 +191,7 @@ Track* Track::clone()
*/
void Track::saveSettings( QDomDocument & doc, QDomElement & element )
{
if( !m_simpleSerializingMode )
if (!isPresetMode())
{
element.setTagName( "track" );
}
Expand All @@ -217,9 +217,9 @@ void Track::saveSettings( QDomDocument & doc, QDomElement & element )
element.appendChild( tsDe );
saveTrackSpecificSettings( doc, tsDe );

if( m_simpleSerializingMode )
if (isPresetMode())
{
m_simpleSerializingMode = false;
setPresetMode(false);
return;
}

Expand Down Expand Up @@ -267,7 +267,7 @@ void Track::loadSettings( const QDomElement & element )
setColor(QColor{element.attribute("color")});
}

if( m_simpleSerializingMode )
if (isPresetMode())
{
QDomNode node = element.firstChild();
while( !node.isNull() )
Expand All @@ -279,7 +279,9 @@ void Track::loadSettings( const QDomElement & element )
}
node = node.nextSibling();
}
m_simpleSerializingMode = false;

setPresetMode(false);

return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/gui/editors/TrackContainerView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ void TrackContainerView::dropEvent( QDropEvent * _de )
{
DataFile dataFile( value );
auto it = dynamic_cast<InstrumentTrack*>(Track::create(Track::Type::Instrument, m_tc));
it->setSimpleSerializing();
it->setPresetMode();
it->loadSettings( dataFile.content().toElement() );
//it->toggledInstrumentTrackButton( true );
_de->accept();
Expand Down
2 changes: 1 addition & 1 deletion src/gui/instrument/InstrumentTrackWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ void InstrumentTrackWindow::saveSettingsBtnClicked()
DataFile dataFile(DataFile::Type::InstrumentTrackSettings);
QDomElement& content(dataFile.content());

m_track->setSimpleSerializing();
m_track->setPresetMode();
m_track->saveSettings(dataFile, content);
//We don't want to save muted & solo settings when we're saving a preset
content.setAttribute("muted", 0);
Expand Down
10 changes: 7 additions & 3 deletions src/tracks/InstrumentTrack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -860,15 +860,19 @@ void InstrumentTrack::saveTrackSpecificSettings( QDomDocument& doc, QDomElement

// Save the midi port info if we are not in song saving mode, e.g. in
// track cloning mode or if we are in song saving mode and the user
// has chosen to discard the MIDI connections.
// has chosen not to discard the MIDI connections.
if (!Engine::getSong()->isSavingProject() ||
!Engine::getSong()->getSaveOptions().discardMIDIConnections.value())
{
// Don't save auto assigned midi device connection
bool hasAuto = m_hasAutoMidiDev;
autoAssignMidiDevice(false);

m_midiPort.saveState( doc, thisElement );
// Only save the MIDI port information if we are not saving a preset.
if (!isPresetMode())
{
m_midiPort.saveState( doc, thisElement );
}

autoAssignMidiDevice(hasAuto);
}
Expand Down Expand Up @@ -1007,7 +1011,7 @@ void InstrumentTrack::replaceInstrument(DataFile dataFile)
int mixerChannel = mixerChannelModel()->value();

InstrumentTrack::removeMidiPortNode(dataFile);
setSimpleSerializing();
setPresetMode();

//Replacing an instrument shouldn't change the solo/mute state.
bool oldMute = isMuted();
Expand Down