From 0aaa57e18e0a363b516a6629164b54cefe08a5b8 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Thu, 9 Sep 2021 10:37:20 +0300 Subject: [PATCH] Assign default name if new virtual desktop has no explicit name If a virtual desktop has empty name, kwin is going to end up in an infinite cycle where VirtualDesktopManager::save() updates the _NET_DESKTOP_NAMES property and then in the next event loop cycle, RootInfoFilter::filter() is going to call VirtualDesktopManager::save() because the _NET_DESKTOP_NAMES property has been changed. This regression has showed up just now because some parts of kwin used to increase virtual desktop count to create new desktops. Recently, that code was ported to VirtualDesktopManager::createVirtualDesktop(). The main difference between createVirtualDesktop() and setCount() is that the latter will set the desktop name to "Desktop N", the former will use user-specified name. If the user-specified name is empty, the createVirtualDesktop() method should assign "Desktop N" name to the virtual desktop according to the docs. However, it's not the case and this change addresses that. --- src/virtualdesktops.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/virtualdesktops.cpp b/src/virtualdesktops.cpp index bac2426f2a..ce463b1401 100644 --- a/src/virtualdesktops.cpp +++ b/src/virtualdesktops.cpp @@ -442,10 +442,15 @@ VirtualDesktop *VirtualDesktopManager::createVirtualDesktop(uint position, const position = qBound(0u, position, static_cast(m_desktops.count())); + QString desktopName = name; + if (desktopName.isEmpty()) { + desktopName = defaultName(position + 1); + } + auto *vd = new VirtualDesktop(this); vd->setX11DesktopNumber(position + 1); vd->setId(generateDesktopId()); - vd->setName(name); + vd->setName(desktopName); connect(vd, &VirtualDesktop::nameChanged, this, [this, vd]() {