Skip to content

Commit

Permalink
Merge pull request #13774 from Eism/close_score_crash_fix
Browse files Browse the repository at this point in the history
fixed #13698: MuseScore crashes after closing score
  • Loading branch information
RomanPudashkin authored Oct 18, 2022
2 parents 65a4e79 + 9272e9a commit 7cb575a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,15 @@ void AbstractInvoker::invoke(int type, const NotifyData& data)
void AbstractInvoker::invokeCallback(int type, const CallBack& c, const NotifyData& data)
{
assert(c.threadID == std::this_thread::get_id());

if (!containsReceiver(c.receiver)) {
return;
}

if (c.receiver && !c.receiver->isConnectedAsync()) {
return;
}

doInvoke(type, c.call, data);
}

Expand Down Expand Up @@ -192,3 +198,16 @@ void AbstractInvoker::removeQInvoker(QInvoker* qi)
std::lock_guard<std::mutex> lock(m_qInvokersMutex);
m_qInvokers.remove(qi);
}

bool AbstractInvoker::containsReceiver(Asyncable* receiver) const
{
for (auto it = m_callbacks.begin(); it != m_callbacks.end(); ++it) {
for (const CallBack& c : it->second) {
if (c.receiver == receiver) {
return true;
}
}
}

return false;
}
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ class AbstractInvoker : public Asyncable::IConnectable
void addQInvoker(QInvoker* qi);
void removeQInvoker(QInvoker* qi);

bool containsReceiver(Asyncable* receiver) const;

std::map<int /*type*/, CallBacks > m_callbacks;

std::mutex m_qInvokersMutex;
Expand Down

0 comments on commit 7cb575a

Please sign in to comment.