Commit 895aee56 authored by David Edmundson's avatar David Edmundson

Guard virtualDesktopManagement being accessed before fetched

Summary:
The WaylandPrivate::virtualDesktopManagement object is loaded
asyncronously.

It's null until we finish fetching the registry.

A code path could call the desktopNames in that time.

Test Plan:
Had a crash
Couldn't reproduce reliably

Reviewers: #plasma, hein

Reviewed By: #plasma, hein

Subscribers: hein, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D19029
parent fafddc4d
......@@ -336,6 +336,9 @@ QVariantList VirtualDesktopInfo::WaylandPrivate::desktopIds() const
QStringList VirtualDesktopInfo::WaylandPrivate::desktopNames() const
{
if (!virtualDesktopManagement) {
return QStringList();
}
QStringList names;
foreach(const QString &id, virtualDesktops) {
......@@ -351,11 +354,18 @@ QStringList VirtualDesktopInfo::WaylandPrivate::desktopNames() const
int VirtualDesktopInfo::WaylandPrivate::desktopLayoutRows() const
{
if (!virtualDesktopManagement) {
return 0;
}
return virtualDesktopManagement->rows();
}
void VirtualDesktopInfo::WaylandPrivate::requestActivate(const QVariant &desktop)
{
if (!virtualDesktopManagement) {
return;
}
KWayland::Client::PlasmaVirtualDesktop *desktopObj = virtualDesktopManagement->getVirtualDesktop(desktop.toString());
if (desktopObj) {
......@@ -365,11 +375,17 @@ void VirtualDesktopInfo::WaylandPrivate::requestActivate(const QVariant &desktop
void VirtualDesktopInfo::WaylandPrivate::requestCreateDesktop(quint32 position)
{
if (!virtualDesktopManagement) {
return;
}
virtualDesktopManagement->requestCreateVirtualDesktop(i18n("New Desktop"), position);
}
void VirtualDesktopInfo::WaylandPrivate::requestRemoveDesktop(quint32 position)
{
if (!virtualDesktopManagement) {
return;
}
if (virtualDesktops.count() == 1) {
return;
}
......
Markdown is supported
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