diff --git a/debian/changelog b/debian/changelog index fd73655..e2ad8dd 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,9 @@ pcmanfm-qt (1.1.0-0ubuntu4) UNRELEASED; urgency=medium * Backport some upstream patches: + - Prevent an empty desktop path. + + https://github.com/lxqt/pcmanfm-qt/pull/1601 + + https://github.com/lxqt/pcmanfm-qt/commit/f1438b -- Simon Quigley Tue, 21 Jun 2022 23:58:05 -0500 diff --git a/debian/patches/series b/debian/patches/series index c4a547c..444bd2e 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -1,2 +1,3 @@ scaling-pr-1596.patch add-manual.patch +upstream-pr-1601.patch diff --git a/debian/patches/upstream-pr-1601.patch b/debian/patches/upstream-pr-1601.patch new file mode 100644 index 0000000..5e03be0 --- /dev/null +++ b/debian/patches/upstream-pr-1601.patch @@ -0,0 +1,91 @@ +From f1438b2b3eec8a1c60532ae5d9fcd654138dc5e4 Mon Sep 17 00:00:00 2001 +From: tsujan +Date: Tue, 21 Jun 2022 11:14:03 +0430 +Subject: [PATCH] Prevent an empty desktop path (#1601) + +Fall back to `$HOME/Desktop` if `~/.config/user-dirs.dirs` doesn't exist or doesn't contain a desktop path. But if `~/.config/user-dirs.dirs` contains an empty desktop path, accept it. + +See https://github.com/lxqt/lxqt-session/issues/439 for the story. +--- + pcmanfm/desktoppreferencesdialog.cpp | 1 - + pcmanfm/xdgdir.cpp | 34 ++++++++++++++++------------ + 2 files changed, 20 insertions(+), 15 deletions(-) + +diff --git a/pcmanfm/desktoppreferencesdialog.cpp b/pcmanfm/desktoppreferencesdialog.cpp +index b25f6435..465095c6 100644 +--- a/pcmanfm/desktoppreferencesdialog.cpp ++++ b/pcmanfm/desktoppreferencesdialog.cpp +@@ -27,7 +27,6 @@ + #include + #include + #include +-#include + #include + #include + #include +diff --git a/pcmanfm/xdgdir.cpp b/pcmanfm/xdgdir.cpp +index 9fd9a7b0..edc5a848 100644 +--- a/pcmanfm/xdgdir.cpp ++++ b/pcmanfm/xdgdir.cpp +@@ -18,10 +18,13 @@ + + #include "xdgdir.h" + #include ++#include + #include + #include + #include + ++static const QRegularExpression desktopRegex(QStringLiteral("XDG_DESKTOP_DIR=\"([^\n]*)\"")); ++ + QString XdgDir::readUserDirsFile() { + QFile file(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + QStringLiteral("/user-dirs.dirs")); + if(file.open(QIODevice::ReadOnly | QIODevice::Text)) { +@@ -34,30 +37,33 @@ QString XdgDir::readUserDirsFile() { + + QString XdgDir::readDesktopDir() { + QString str = readUserDirsFile(); +- if(str.isEmpty()) +- return QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + QStringLiteral("/Desktop"); +- QRegExp reg(QStringLiteral("XDG_DESKTOP_DIR=\"([^\n]*)\"")); +- if(reg.lastIndexIn(str) != -1) { +- str = reg.cap(1); +- if(str.startsWith(QStringLiteral("$HOME"))) +- str = QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + str.mid(5); +- return str; ++ if(!str.isEmpty()) { ++ QRegularExpressionMatch match; ++ if(str.lastIndexOf(desktopRegex, -1, &match) != -1) { ++ str = match.captured(1); ++ if(str.startsWith(QStringLiteral("$HOME"))) { ++ str = QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + str.mid(5); ++ } ++ return str; ++ } + } +- return QString(); ++ return QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + QStringLiteral("/Desktop"); + } + + void XdgDir::setDesktopDir(QString path) { + QString home = QStandardPaths::writableLocation(QStandardPaths::HomeLocation); +- if(path.startsWith(home)) ++ if(path.startsWith(home)) { + path = QStringLiteral("$HOME") + path.mid(home.length()); ++ } + QString str = readUserDirsFile(); +- QRegExp reg(QStringLiteral("XDG_DESKTOP_DIR=\"([^\n]*)\"")); + QString line = QStringLiteral("XDG_DESKTOP_DIR=\"") + path + QLatin1Char('\"'); +- if(reg.indexIn(str) != -1) +- str.replace(reg, line); ++ if(str.contains(desktopRegex)) { ++ str.replace(desktopRegex, line); ++ } + else { +- if(!str.endsWith(QLatin1Char('\n'))) ++ if(!str.endsWith(QLatin1Char('\n'))) { + str += QLatin1Char('\n'); ++ } + str += line + QLatin1Char('\n'); + } + QString dir = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation);