mirror of https://github.com/procxx/kepka.git
trying to fix undefined behaviour in notifyShowNext()
This commit is contained in:
parent
62a0878198
commit
318794692f
|
@ -1415,7 +1415,8 @@ void Window::notifyShowNext(NotifyWindow *remove) {
|
||||||
while (count > 0) {
|
while (count > 0) {
|
||||||
uint64 next = 0;
|
uint64 next = 0;
|
||||||
HistoryItem *notifyItem = 0;
|
HistoryItem *notifyItem = 0;
|
||||||
NotifyWaiters::iterator notifyWaiter;
|
History *notifyHistory = 0;
|
||||||
|
NotifyWaiters::iterator notifyWaiter = notifyWaiters.end();
|
||||||
for (NotifyWaiters::iterator i = notifyWaiters.begin(); i != notifyWaiters.end(); ++i) {
|
for (NotifyWaiters::iterator i = notifyWaiters.begin(); i != notifyWaiters.end(); ++i) {
|
||||||
History *history = i.key();
|
History *history = i.key();
|
||||||
if (history->currentNotification() && history->currentNotification()->id != i.value().msg) {
|
if (history->currentNotification() && history->currentNotification()->id != i.value().msg) {
|
||||||
|
@ -1423,6 +1424,7 @@ void Window::notifyShowNext(NotifyWindow *remove) {
|
||||||
if (j == notifyWhenMaps.end()) {
|
if (j == notifyWhenMaps.end()) {
|
||||||
history->clearNotifications();
|
history->clearNotifications();
|
||||||
i = notifyWaiters.erase(i);
|
i = notifyWaiters.erase(i);
|
||||||
|
if (notifyHistory) notifyWaiter = notifyWaiters.find(notifyHistory);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
do {
|
do {
|
||||||
|
@ -1438,12 +1440,14 @@ void Window::notifyShowNext(NotifyWindow *remove) {
|
||||||
if (!history->currentNotification()) {
|
if (!history->currentNotification()) {
|
||||||
notifyWhenMaps.remove(history);
|
notifyWhenMaps.remove(history);
|
||||||
i = notifyWaiters.erase(i);
|
i = notifyWaiters.erase(i);
|
||||||
|
if (notifyHistory) notifyWaiter = notifyWaiters.find(notifyHistory);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
uint64 when = i.value().when;
|
uint64 when = i.value().when;
|
||||||
if (!notifyItem || next > when) {
|
if (!notifyItem || next > when) {
|
||||||
next = when;
|
next = when;
|
||||||
notifyItem = history->currentNotification();
|
notifyItem = history->currentNotification();
|
||||||
|
notifyHistory = history;
|
||||||
notifyWaiter = i;
|
notifyWaiter = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1510,8 +1514,8 @@ void Window::notifyShowNext(NotifyWindow *remove) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!history->hasNotification()) {
|
if (!history->hasNotification()) {
|
||||||
notifyWaiters.erase(notifyWaiter);
|
if (notifyWaiter != notifyWaiters.cend()) notifyWaiters.erase(notifyWaiter);
|
||||||
if (j != notifyWhenMaps.end()) notifyWhenMaps.erase(j);
|
if (j != notifyWhenMaps.cend()) notifyWhenMaps.erase(j);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue