fix: read plasmashell version more reliably

In some cases, `plasmashell -v` crashes, which makes `readAllStandardOutput`
fail, although the version is printed out by the process before crashing.
See https://bugs.kde.org/show_bug.cgi?id=467696 and
https://bugreports.qt.io/browse/QTBUG-112258 for the details of the crash.

Instead, read the libtaskmanager version from CMake, which is much more
reliable.
work/fuf/qt6
Aroun Olorin 2 years ago committed by Nate Graham
parent 06fbe1fd4d
commit 4f93251d8c

@ -26,3 +26,4 @@ Dependencies:
'frameworks/kwayland': '@latest' 'frameworks/kwayland': '@latest'
'frameworks/kwindowsystem': '@latest' 'frameworks/kwindowsystem': '@latest'
'frameworks/kxmlgui': '@latest' 'frameworks/kxmlgui': '@latest'
'plasma/plasma-workspace': '@same'

@ -35,6 +35,9 @@ find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED NO_MODULE COMPONENTS DBus Gui
find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS
Activities Archive CoreAddons GuiAddons Crash DBusAddons Declarative GlobalAccel Kirigami2 Activities Archive CoreAddons GuiAddons Crash DBusAddons Declarative GlobalAccel Kirigami2
I18n IconThemes KIO NewStuff Notifications Plasma PlasmaQuick Wayland WindowSystem XmlGui) I18n IconThemes KIO NewStuff Notifications Plasma PlasmaQuick Wayland WindowSystem XmlGui)
find_package(LibTaskManager REQUIRED)
add_definitions(-DPLASMA_WORKSPACE_VERSION="${LibTaskManager_VERSION}")
find_package(X11 REQUIRED) find_package(X11 REQUIRED)
set_package_properties(X11 PROPERTIES DESCRIPTION "X11 libraries" set_package_properties(X11 PROPERTIES DESCRIPTION "X11 libraries"

@ -61,35 +61,24 @@ uint Environment::makeVersion(uint major, uint minor, uint release) const
uint Environment::identifyPlasmaDesktopVersion() uint Environment::identifyPlasmaDesktopVersion()
{ {
//! Identify Plasma Desktop version //! Identify Plasma Desktop version
QProcess process; QStringList plasmaDesktopVersionParts = QString(PLASMA_WORKSPACE_VERSION).split(".");
process.start("plasmashell", QStringList() << "-v");
process.waitForFinished();
QString output(process.readAllStandardOutput());
QStringList stringSplit = output.split(" "); if (plasmaDesktopVersionParts.count() == 3) {
if (stringSplit.count() >= 2) {
qDebug() << " /////////////////////////"; qDebug() << " /////////////////////////";
QString cleanVersionString = stringSplit[1].remove("\n"); uint maj = plasmaDesktopVersionParts[0].toUInt();
QStringList plasmaDesktopVersionParts = cleanVersionString.split("."); uint min = plasmaDesktopVersionParts[1].toUInt();
uint rel = plasmaDesktopVersionParts[2].toUInt();
if (plasmaDesktopVersionParts.count() == 3) {
uint maj = plasmaDesktopVersionParts[0].toUInt();
uint min = plasmaDesktopVersionParts[1].toUInt();
uint rel = plasmaDesktopVersionParts[2].toUInt();
if (maj > 0) {
uint desktopVersion = makeVersion(maj, min, rel); if (maj > 0) {
uint desktopVersion = makeVersion(maj, min, rel);
QString message("Plasma Desktop version: " + QString::number(maj) + "." QString message("Plasma Desktop version: " + QString::number(maj) + "."
+ QString::number(min) + "." + QString::number(rel) + QString::number(min) + "." + QString::number(rel)
+ " (" + QString::number(desktopVersion) + ")"); + " (" + QString::number(desktopVersion) + ")");
qDebug() << message; qDebug() << message;
qDebug() << " /////////////////////////"; qDebug() << " /////////////////////////";
return desktopVersion; return desktopVersion;
}
} }
qDebug() << " /////////////////////////"; qDebug() << " /////////////////////////";

Loading…
Cancel
Save