From e5b889b88ac11e908cb3a0012c1dc0a6e6d9d8ab Mon Sep 17 00:00:00 2001 From: Michele Spagnolo Date: Wed, 7 Dec 2022 14:09:00 +0100 Subject: [PATCH 1/6] Correct brackets bug at score creation --- src/notation/internal/notationparts.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/notation/internal/notationparts.cpp b/src/notation/internal/notationparts.cpp index 6b67c025d5f3e..8e533885a3703 100644 --- a/src/notation/internal/notationparts.cpp +++ b/src/notation/internal/notationparts.cpp @@ -941,10 +941,6 @@ void NotationParts::appendStaves(Part* part, const InstrumentTemplate& templ, co } initStaff(staff, templ, staffType, staffIndex); - if (lastStaffIndex > 0) { - staff->setBarLineSpan(score()->staff(lastStaffIndex - 1)->barLineSpan()); - } - insertStaff(staff, staffIndex); } From ded35209429fffab4e7a0663b67aac69d1aab2f9 Mon Sep 17 00:00:00 2001 From: Roman Pudashkin Date: Tue, 10 Jan 2023 17:58:03 +0200 Subject: [PATCH 2/6] fix #15292: Unlike other OS, when the user tries to open a file on macOS, the path to the file will be contained in the QEvent::FileOpen event. This event can be postponed when opening the application. So we might get into a situation where we have already started loading the Home page (as the default start page), but we still haven't received QEvent::FileOpen. So that is why it is important to process QEvent::FileOpen as early as possible --- src/appshell/appshellmodule.cpp | 8 ++++++++ src/appshell/appshellmodule.h | 1 + 2 files changed, 9 insertions(+) diff --git a/src/appshell/appshellmodule.cpp b/src/appshell/appshellmodule.cpp index da2fa717fbe0f..8cc018ede3a90 100644 --- a/src/appshell/appshellmodule.cpp +++ b/src/appshell/appshellmodule.cpp @@ -200,6 +200,14 @@ void AppShellModule::onInit(const IApplication::RunMode&) #endif } +void AppShellModule::onAllInited(const framework::IApplication::RunMode&) +{ + //! NOTE: process QEvent::FileOpen as early as possible if it was postponed +#ifdef Q_OS_MACOS + qApp->processEvents(); +#endif +} + void AppShellModule::onDeinit() { s_sessionsManager->deinit(); diff --git a/src/appshell/appshellmodule.h b/src/appshell/appshellmodule.h index ac201c856eeaf..c0514c6c31620 100644 --- a/src/appshell/appshellmodule.h +++ b/src/appshell/appshellmodule.h @@ -41,6 +41,7 @@ class AppShellModule : public modularity::IModuleSetup void onPreInit(const framework::IApplication::RunMode& mode) override; void onInit(const framework::IApplication::RunMode& mode) override; + void onAllInited(const framework::IApplication::RunMode& mode) override; void onDeinit() override; }; } From 715509ef33107e3f3068067a3562f8b823c26b8b Mon Sep 17 00:00:00 2001 From: Michele Spagnolo Date: Mon, 19 Dec 2022 18:26:34 +0100 Subject: [PATCH 3/6] Fix duplicate system objects in parts --- src/engraving/libmscore/excerpt.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/engraving/libmscore/excerpt.cpp b/src/engraving/libmscore/excerpt.cpp index 1eb7984650c69..ee316ce67faf5 100644 --- a/src/engraving/libmscore/excerpt.cpp +++ b/src/engraving/libmscore/excerpt.cpp @@ -771,7 +771,8 @@ static MeasureBase* cloneMeasure(MeasureBase* mb, Score* score, const Score* osc if (e->generated()) { continue; } - if ((e->track() == srcTrack && strack != mu::nidx) || (e->systemFlag() && srcTrack == 0)) { + if ((e->track() == srcTrack && strack != mu::nidx && !e->systemFlag()) + || (e->systemFlag() && srcTrack == 0 && e->track() == srcTrack)) { EngravingItem* ne = e->linkedClone(); processLinkedClone(ne, score, strack); if (!ns) { @@ -1479,8 +1480,8 @@ void Excerpt::cloneStaff2(Staff* srcStaff, Staff* dstStaff, const Fraction& star for (EngravingItem* e : oseg->annotations()) { if (e->generated() - || (e->track() != srcTrack && !e->systemFlag()) // system items must be cloned even if they are on different tracks - || (e->systemFlag() && score->nstaves() > 1)) { // ...but only once! + || (e->track() != srcTrack && !(e->systemFlag() && e->track() == 0)) // system items must be cloned even if they are on different tracks + || (e->track() != srcTrack && e->systemFlag() && e->findLinkedInScore(score))) { // ...but only once! continue; } From f5af41489071838c9d115943a4a302e6b72612e3 Mon Sep 17 00:00:00 2001 From: Casper Jeukendrup <48658420+cbjeukendrup@users.noreply.github.com> Date: Wed, 28 Dec 2022 20:34:30 +0100 Subject: [PATCH 4/6] WASAPI Driver: don't crash (or rather hang) when starting client fails We were waiting infinitely for the WASAPI_Client_Started event, but when there was an error while starting the client, that event would never be signaled. So MuseScore would be stuck infinitely on launch. --- .../internal/platform/win/wasapiaudioclient.cpp | 12 ++++++++++-- .../internal/platform/win/wasapiaudioclient.h | 3 ++- .../internal/platform/win/wasapiaudiodriver.cpp | 15 +++++++++++++-- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/framework/audio/internal/platform/win/wasapiaudioclient.cpp b/src/framework/audio/internal/platform/win/wasapiaudioclient.cpp index 2d05ab2f81806..1af58db0d3bd9 100644 --- a/src/framework/audio/internal/platform/win/wasapiaudioclient.cpp +++ b/src/framework/audio/internal/platform/win/wasapiaudioclient.cpp @@ -29,8 +29,9 @@ using namespace winrt::Windows::Foundation; using namespace winrt::Windows::Media::Devices; using namespace winrt::Windows::Devices::Enumeration; -WasapiAudioClient::WasapiAudioClient(HANDLE clientStartedEvent, HANDLE clientStoppedEvent) - : m_clientStartedEvent(clientStartedEvent), m_clientStoppedEvent(clientStoppedEvent) +WasapiAudioClient::WasapiAudioClient(HANDLE clientStartedEvent, HANDLE clientFailedToStartEvent, HANDLE clientStoppedEvent) + : m_clientStartedEvent(clientStartedEvent), m_clientFailedToStartEvent(clientFailedToStartEvent), m_clientStoppedEvent( + clientStoppedEvent) { check_hresult(MFStartup(MF_VERSION, MFSTARTUP_LITE)); } @@ -218,6 +219,8 @@ HRESULT WasapiAudioClient::ActivateCompleted(IActivateAudioInterfaceAsyncOperati m_audioRenderClient = nullptr; m_sampleReadyAsyncResult = nullptr; + SetEvent(m_clientFailedToStartEvent); + // Must return S_OK even on failure. return S_OK; } @@ -370,6 +373,8 @@ void WasapiAudioClient::startPlayback() noexcept } catch (...) { hresult error = to_hresult(); setStateAndNotify(DeviceState::Error, error); + + SetEvent(m_clientFailedToStartEvent); } } @@ -398,6 +403,9 @@ HRESULT WasapiAudioClient::onStartPlayback(IMFAsyncResult*) noexcept return S_OK; } catch (...) { setStateAndNotify(DeviceState::Error, to_hresult()); + + SetEvent(m_clientFailedToStartEvent); + // Must return S_OK. return S_OK; } diff --git a/src/framework/audio/internal/platform/win/wasapiaudioclient.h b/src/framework/audio/internal/platform/win/wasapiaudioclient.h index 97993d2b0532b..4edab29a4a34c 100644 --- a/src/framework/audio/internal/platform/win/wasapiaudioclient.h +++ b/src/framework/audio/internal/platform/win/wasapiaudioclient.h @@ -29,7 +29,7 @@ namespace winrt { struct WasapiAudioClient : implements { public: - WasapiAudioClient(HANDLE clientStartedEvent, HANDLE clientStoppedEvent); + WasapiAudioClient(HANDLE clientStartedEvent, HANDLE clientFailedToStartEvent, HANDLE clientStoppedEvent); ~WasapiAudioClient(); void setHardWareOffload(bool value); @@ -99,6 +99,7 @@ struct WasapiAudioClient : implements wasapiClient; @@ -54,6 +55,7 @@ static WasapiData s_data; WasapiAudioDriver::WasapiAudioDriver() { s_data.clientStartedEvent = CreateEvent(NULL, FALSE, FALSE, L"WASAPI_Client_Started"); + s_data.clientFailedToStartEvent = CreateEvent(NULL, FALSE, FALSE, L"WASAPI_Client_Failed_To_Start"); s_data.clientStoppedEvent = CreateEvent(NULL, FALSE, FALSE, L"WASAPI_Client_Stopped"); m_devicesListener.startWithCallback([this]() { @@ -77,7 +79,8 @@ std::string WasapiAudioDriver::name() const bool WasapiAudioDriver::open(const Spec& spec, Spec* activeSpec) { if (!s_data.wasapiClient.get()) { - s_data.wasapiClient = make_self(s_data.clientStartedEvent, s_data.clientStoppedEvent); + s_data.wasapiClient + = make_self(s_data.clientStartedEvent, s_data.clientFailedToStartEvent, s_data.clientStoppedEvent); } m_desiredSpec = spec; @@ -102,7 +105,15 @@ bool WasapiAudioDriver::open(const Spec& spec, Spec* activeSpec) s_data.wasapiClient->asyncInitializeAudioDevice(deviceId); - WaitForSingleObject(s_data.clientStartedEvent, INFINITE); + static constexpr DWORD handleCount = 2; + const HANDLE handles[handleCount] = { s_data.clientStartedEvent, s_data.clientFailedToStartEvent }; + + DWORD waitResult = WaitForMultipleObjects(handleCount, handles, false, INFINITE); + if (waitResult != WAIT_OBJECT_0) { + // Either the event was the second event (namely s_data.clientFailedToStartEvent) + // Or some wait error occurred + return false; + } m_activeSpec = m_desiredSpec; m_activeSpec.sampleRate = s_data.wasapiClient->sampleRate(); From f2640a05a82620aee535aad7132c2e278b29dad5 Mon Sep 17 00:00:00 2001 From: Aaron Sattely Date: Mon, 19 Dec 2022 15:54:48 -0500 Subject: [PATCH 5/6] add initial score creation tempo markings to all system object staves --- src/notation/internal/masternotation.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/notation/internal/masternotation.cpp b/src/notation/internal/masternotation.cpp index 94981f719b46a..5585c5d4574f8 100644 --- a/src/notation/internal/masternotation.cpp +++ b/src/notation/internal/masternotation.cpp @@ -431,6 +431,12 @@ void MasterNotation::applyOptions(mu::engraving::MasterScore* score, const Score tt->setFollowText(true); tt->setTrack(0); seg->add(tt); + for (auto staff : score->getSystemObjectStaves()) { + TempoText* linkedTt = toTempoText(tt->linkedClone()); + linkedTt->setScore(score); + linkedTt->setTrack(staff->idx() * VOICES); + seg->add(linkedTt); + } } score->setUpTempoMap(); From 3f24594504bb3a32b676923ec5cf96c61482fbfd Mon Sep 17 00:00:00 2001 From: Roman Pudashkin Date: Thu, 12 Jan 2023 14:33:58 +0200 Subject: [PATCH 6/6] ported missing function --- src/engraving/libmscore/engravingobject.cpp | 16 ++++++++++++++++ src/engraving/libmscore/engravingobject.h | 1 + 2 files changed, 17 insertions(+) diff --git a/src/engraving/libmscore/engravingobject.cpp b/src/engraving/libmscore/engravingobject.cpp index 0b3be1debe5f6..a5ca9e27c4e2c 100644 --- a/src/engraving/libmscore/engravingobject.cpp +++ b/src/engraving/libmscore/engravingobject.cpp @@ -676,6 +676,22 @@ bool EngravingObject::isLinked(EngravingObject* se) const return _links->contains(se); } +//--------------------------------------------------------- +// findLinkedInScore +/// if exists, returns the linked object in the required +/// score, else returns null +//--------------------------------------------------------- + +EngravingObject* EngravingObject::findLinkedInScore(Score* score) const +{ + if (score == this || !_links || _links->empty()) { + return nullptr; + } + auto findElem = std::find_if(_links->begin(), _links->end(), + [score](EngravingObject* engObj) { return engObj && engObj->score() == score; }); + return findElem != _links->end() ? *findElem : nullptr; +} + //--------------------------------------------------------- // undoUnlink //--------------------------------------------------------- diff --git a/src/engraving/libmscore/engravingobject.h b/src/engraving/libmscore/engravingobject.h index 4d5f5bcce3d0d..212a76a835c15 100644 --- a/src/engraving/libmscore/engravingobject.h +++ b/src/engraving/libmscore/engravingobject.h @@ -295,6 +295,7 @@ class EngravingObject void linkTo(EngravingObject*); void unlink(); bool isLinked(EngravingObject* se = nullptr) const; + EngravingObject* findLinkedInScore(Score* score) const; virtual void undoUnlink(); LinkedObjects* links() const { return _links; }