Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/engraving/infrastructure/eid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ EID EID::fromStdString(const std::string_view& s)
EID EID::newUnique()
{
static std::random_device s_device;
static std::mt19937_64 s_engine(s_device());
static std::uniform_int_distribution<uint64_t> s_unifDist;
thread_local static std::mt19937_64 s_engine(s_device());
thread_local static std::uniform_int_distribution<uint64_t> s_unifDist;

return EID(s_unifDist(s_engine), s_unifDist(s_engine));
}
Expand Down
4 changes: 4 additions & 0 deletions src/engraving/infrastructure/eidregister.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ EID EIDRegister::newEIDForItem(const EngravingObject* item)

void EIDRegister::registerItemEID(const EID& eid, const EngravingObject* item)
{
std::lock_guard lock(m_mutex);
IF_ASSERT_FAILED(eid.isValid() && item) {
return;
}
Expand All @@ -58,6 +59,7 @@ void EIDRegister::registerItemEID(const EID& eid, const EngravingObject* item)

void EIDRegister::removeItem(const EngravingObject* item)
{
std::lock_guard lock(m_mutex);
// NOTE: needed only when elements are removed during read (e.g. broken spanners)

auto itemIter = m_itemToEid.find(const_cast<EngravingObject*>(item));
Expand All @@ -78,6 +80,7 @@ void EIDRegister::removeItem(const EngravingObject* item)

EngravingObject* EIDRegister::itemFromEID(const EID& eid) const
{
std::shared_lock lock(m_mutex);
auto iter = m_eidToItem.find(eid);
IF_ASSERT_FAILED(iter != m_eidToItem.end()) {
return nullptr;
Expand All @@ -87,6 +90,7 @@ EngravingObject* EIDRegister::itemFromEID(const EID& eid) const

EID EIDRegister::EIDFromItem(const EngravingObject* item) const
{
std::shared_lock lock(m_mutex);
auto iter = m_itemToEid.find(const_cast<EngravingObject*>(item));
return iter == m_itemToEid.end() ? EID::invalid() : iter->second;
}
3 changes: 3 additions & 0 deletions src/engraving/infrastructure/eidregister.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#include <cstdint>
#include <unordered_map>
#include <shared_mutex>

#include "eid.h"
#include "../types/types.h"
Expand All @@ -49,5 +50,7 @@ class EIDRegister
std::unordered_map<EngravingObject*, EID> m_itemToEid;

uint64_t m_maxValTestMode = 0;

mutable std::shared_mutex m_mutex;
};
}
6 changes: 4 additions & 2 deletions src/engraving/rw/write/writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,10 @@ void Writer::write(Score* score, XmlWriter& xml, WriteContext& ctx, compat::Writ

ctx.setCurTrack(0);

// Let's decide: write midi mapping to a file or not
score->masterScore()->checkMidiMapping();
if (score->isMaster()) {
// Let's decide: write midi mapping to a file or not
score->masterScore()->checkMidiMapping();
}

auto shouldWritePart = [&ctx, score, staffStart, staffEnd](const Part* part) {
if (!ctx.shouldWriteRange()) {
Expand Down
2 changes: 1 addition & 1 deletion src/engraving/rw/write/writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
namespace mu::engraving::write {
class Writer : public rw::IWriter
{
muse::GlobalInject<muse::IApplication> application;
muse::GlobalThreadSafeInject<muse::IApplication> application;

public:

Expand Down
Loading