Commit 11fd0f2c authored by Aaron J. Seigo's avatar Aaron J. Seigo
Browse files

don't crash when the list is empty

the do/while construct would die on an empty list. in theory this
shouldn't happen because we are asking with a Task pointer which
should only exist if there are, well, windows. however, due to the
async nature of windowing systems, during the time of the call all
of this can change.

BUG:281035
parent 7a4604e9
......@@ -469,28 +469,31 @@ int TaskManager::numberOfDesktops() const
return KWindowSystem::numberOfDesktops();
}
bool TaskManager::isOnTop(const Task* task) const
bool TaskManager::isOnTop(const Task *task) const
{
if (!task) {
return false;
}
QList<WId> list = KWindowSystem::stackingOrder();
QList<WId>::const_iterator begin(list.constBegin());
QList<WId>::const_iterator it = list.constBegin() + (list.size() - 1);
do {
Task *t = d->tasksByWId.value(*it);
if (t) {
if (t == task) {
return true;
}
QListIterator<WId> it(list);
it.toBack();
while (it.hasPrevious()) {
Task *t = d->tasksByWId.value(it.previous());
if (!t) {
continue;
}
if (t == task) {
return true;
}
#ifndef Q_WS_WIN
if (!t->isIconified() && (t->isAlwaysOnTop() == task->isAlwaysOnTop())) {
return false;
}
#endif
if (!t->isIconified() && (t->isAlwaysOnTop() == task->isAlwaysOnTop())) {
return false;
}
} while (it-- != begin);
#endif
}
return false;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment