Skip to content

Commit

Permalink
Don't recalculate the song length for every added TCO while loading (L…
Browse files Browse the repository at this point in the history
…MMS#5236)

Don't make LMMS calculate the song length for every added TCO when a new project is created or a project is loaded. Instead do it only once afterwards. This is accomplished by preventing any calculations in `Song::updateLength` if a song is currently loaded. `Song::updateLength` is then called immediately after the loading flag has been set to `false` in both cases.

---------

Co-authored-by: IanCaio <[email protected]>
  • Loading branch information
2 people authored and Rossmaxx committed Jun 15, 2024
1 parent fe7efa9 commit 10ba45d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/core/Song.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,8 @@ void Song::playMidiClip( const MidiClip* midiClipToPlay, bool loop )

void Song::updateLength()
{
if (m_loadingProject) { return; }

m_length = 0;
m_tracksMutex.lockForRead();
for (auto track : tracks())
Expand Down Expand Up @@ -963,7 +965,7 @@ void Song::createNewProject()
QCoreApplication::instance()->processEvents();

m_loadingProject = false;

updateLength();
Engine::patternStore()->updateAfterTrackAdd();

Engine::projectJournal()->setJournalling( true );
Expand Down Expand Up @@ -1206,6 +1208,7 @@ void Song::loadProject( const QString & fileName )
}

m_loadingProject = false;
updateLength();
setModified(false);
m_loadOnLaunch = false;
}
Expand Down

0 comments on commit 10ba45d

Please sign in to comment.