Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed #13698: MuseScore crashes after closing score #13774

Merged
merged 1 commit into from
Oct 18, 2022
Merged
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
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
Eism marked this conversation as resolved.
Show resolved Hide resolved
{
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