Skip to content

Commit 49c6186

Browse files
committed
Fix destruction bugs
1 parent 5fce8c9 commit 49c6186

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

src/plugins/audio/internal/addon/ProjectAudioAddOn.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ namespace Audio::Internal {
6464
}
6565

6666
ProjectAudioAddOn::~ProjectAudioAddOn() {
67-
if (m_context && AudioSystem::outputSystem()) {
67+
if (m_context && AudioSystem::instance() && AudioSystem::outputSystem()) {
6868
GlobalAudioContext::preMixer()->removeSource(m_context->preMixer());
6969
if (m_metronomeAudioSource) {
7070
m_metronomeAudioSource->setDetector(nullptr);

src/plugins/coreplugin/internal/notification/NotificationViewModel.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,21 @@ namespace Core::Internal {
106106
});
107107
const auto index = static_cast<int>(std::distance(messages.cbegin(), it));
108108
messages.insert(index, message);
109+
// A message can outlive the NotificationManager that added it (e.g. on application exit a
110+
// window-local manager may be destroyed before its messages). In that case no messageRemoved
111+
// signal will reach this view model, so purge the stale pointer here to keep m_messages and
112+
// m_bubbleMessages free of dangling pointers. The message is already being destroyed when
113+
// this handler runs and must not be dereferenced.
114+
connect(message, &QObject::destroyed, this, [this, message] {
115+
const bool wasTop = !m_messages.isEmpty() && m_messages.last() == message;
116+
if (m_messages.removeAll(message) == 0 && m_bubbleMessages.removeAll(message) == 0) {
117+
return;
118+
}
119+
if (wasTop) {
120+
updateTopMessageTitleConnection();
121+
Q_EMIT topMessageTitleChanged(topMessageTitle());
122+
}
123+
});
109124
return index;
110125
}
111126

0 commit comments

Comments
 (0)