platforms/virtual: Add new outputs before removing old outputs
This is to prevent hitting the case where there are no any outputs. Ideally, it shouldn't matter in which order outputs are added or removed, but the Workspace and AbstractClient subclasses don't work with true headless mode. If there are no outputs, kwin can crash.
This commit is contained in:
parent
f8ad513648
commit
89d49b4d5d
1 changed files with 13 additions and 10 deletions
|
@ -116,16 +116,8 @@ void VirtualBackend::setVirtualOutputs(int count, QVector<QRect> geometries, QVe
|
|||
Q_ASSERT(geometries.size() == 0 || geometries.size() == count);
|
||||
Q_ASSERT(scales.size() == 0 || scales.size() == count);
|
||||
|
||||
while (!m_outputsEnabled.isEmpty()) {
|
||||
VirtualOutput *output = m_outputsEnabled.takeLast();
|
||||
Q_EMIT outputDisabled(output);
|
||||
}
|
||||
|
||||
while (!m_outputs.isEmpty()) {
|
||||
VirtualOutput *output = m_outputs.takeLast();
|
||||
Q_EMIT outputRemoved(output);
|
||||
delete output;
|
||||
}
|
||||
const QVector<VirtualOutput *> disabled = m_outputsEnabled;
|
||||
const QVector<VirtualOutput *> removed = m_outputs;
|
||||
|
||||
int sumWidth = 0;
|
||||
for (int i = 0; i < count; i++) {
|
||||
|
@ -146,6 +138,17 @@ void VirtualBackend::setVirtualOutputs(int count, QVector<QRect> geometries, QVe
|
|||
Q_EMIT outputEnabled(vo);
|
||||
}
|
||||
|
||||
for (VirtualOutput *output : disabled) {
|
||||
m_outputsEnabled.removeOne(output);
|
||||
Q_EMIT outputDisabled(output);
|
||||
}
|
||||
|
||||
for (VirtualOutput *output : removed) {
|
||||
m_outputs.removeOne(output);
|
||||
Q_EMIT outputRemoved(output);
|
||||
delete output;
|
||||
}
|
||||
|
||||
Q_EMIT screensQueried();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue