From 6ec1ced49cc9845832aa7c451167e0b143fee785 Mon Sep 17 00:00:00 2001 From: "Raine M. Ekman" Date: Thu, 30 May 2024 19:37:08 +0300 Subject: [PATCH] Don't recalculate the song length for every added TCO while loading (#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 --- src/core/Song.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/core/Song.cpp b/src/core/Song.cpp index 81a263287..392e9e256 100644 --- a/src/core/Song.cpp +++ b/src/core/Song.cpp @@ -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()) @@ -963,7 +965,7 @@ void Song::createNewProject() QCoreApplication::instance()->processEvents(); m_loadingProject = false; - + updateLength(); Engine::patternStore()->updateAfterTrackAdd(); Engine::projectJournal()->setJournalling( true ); @@ -1206,6 +1208,7 @@ void Song::loadProject( const QString & fileName ) } m_loadingProject = false; + updateLength(); setModified(false); m_loadOnLaunch = false; }