Fix a crash in ScreenEdges::recreateEdges()

Edge::activatesForPointer() needs the virtual desktop manager to be
fully initialized. It's also important to know that the
activatesForPointer() function can be called when recreating screen
edges.

During the startup process, the Workspace can update outputs, which
will also trigger screen edge recreation. The problem is that
the Workspace does that before the virtual desktop manager is fully
initialized.

As a potential solution, make the Workspace update outputs a bit later.
wilder/Plasma/6.3
Vlad Zahorodnii 1 year ago
parent b786c7e930
commit d279586be3
  1. 40
      src/workspace.cpp

@ -177,25 +177,6 @@ void Workspace::init()
connect(options, &Options::separateScreenFocusChanged, m_focusChain.get(), &FocusChain::setSeparateScreenFocus);
m_focusChain->setSeparateScreenFocus(options->isSeparateScreenFocus());
if (waylandServer()) {
m_outputConfigStore = std::make_unique<OutputConfigurationStore>();
const auto applySensorChanges = [this]() {
m_orientationSensor->setEnabled(m_outputConfigStore->isAutoRotateActive(kwinApp()->outputBackend()->outputs(), kwinApp()->tabletModeManager()->effectiveTabletMode()));
const auto opt = m_outputConfigStore->queryConfig(kwinApp()->outputBackend()->outputs(), m_lidSwitchTracker->isLidClosed(), m_orientationSensor->reading(), kwinApp()->tabletModeManager()->effectiveTabletMode());
if (opt) {
const auto &[config, order, type] = *opt;
applyOutputConfiguration(config, order);
}
};
connect(m_lidSwitchTracker.get(), &LidSwitchTracker::lidStateChanged, this, applySensorChanges);
connect(m_orientationSensor.get(), &OrientationSensor::orientationChanged, this, applySensorChanges);
connect(kwinApp()->tabletModeManager(), &TabletModeManager::tabletModeChanged, this, applySensorChanges);
m_orientationSensor->setEnabled(m_outputConfigStore->isAutoRotateActive(kwinApp()->outputBackend()->outputs(), kwinApp()->tabletModeManager()->effectiveTabletMode()));
}
slotOutputBackendOutputsQueried();
connect(kwinApp()->outputBackend(), &OutputBackend::outputsQueried, this, &Workspace::slotOutputBackendOutputsQueried);
// create VirtualDesktopManager and perform dependency injection
VirtualDesktopManager *vds = VirtualDesktopManager::self();
connect(vds, &VirtualDesktopManager::desktopAdded, this, &Workspace::slotDesktopAdded);
@ -216,9 +197,28 @@ void Workspace::init()
// makes sure any autogenerated id is saved, necessary as in case of xwayland, load will be called 2 times
// load is needed to be called again when starting xwayalnd to sync to RootInfo, see BUG 385260
vds->save();
vds->setCurrent(m_initialDesktop);
if (waylandServer()) {
m_outputConfigStore = std::make_unique<OutputConfigurationStore>();
const auto applySensorChanges = [this]() {
m_orientationSensor->setEnabled(m_outputConfigStore->isAutoRotateActive(kwinApp()->outputBackend()->outputs(), kwinApp()->tabletModeManager()->effectiveTabletMode()));
const auto opt = m_outputConfigStore->queryConfig(kwinApp()->outputBackend()->outputs(), m_lidSwitchTracker->isLidClosed(), m_orientationSensor->reading(), kwinApp()->tabletModeManager()->effectiveTabletMode());
if (opt) {
const auto &[config, order, type] = *opt;
applyOutputConfiguration(config, order);
}
};
connect(m_lidSwitchTracker.get(), &LidSwitchTracker::lidStateChanged, this, applySensorChanges);
connect(m_orientationSensor.get(), &OrientationSensor::orientationChanged, this, applySensorChanges);
connect(kwinApp()->tabletModeManager(), &TabletModeManager::tabletModeChanged, this, applySensorChanges);
m_orientationSensor->setEnabled(m_outputConfigStore->isAutoRotateActive(kwinApp()->outputBackend()->outputs(), kwinApp()->tabletModeManager()->effectiveTabletMode()));
}
slotOutputBackendOutputsQueried();
connect(kwinApp()->outputBackend(), &OutputBackend::outputsQueried, this, &Workspace::slotOutputBackendOutputsQueried);
reconfigureTimer.setSingleShot(true);
m_rearrangeTimer.setSingleShot(true);

Loading…
Cancel
Save