From 316bf124437f4aaef10c29db5a158092ca7a832a Mon Sep 17 00:00:00 2001 From: Jan Grulich Date: Wed, 7 Oct 2020 08:36:44 +0200 Subject: [PATCH] FileChooser portal: skip empty filters to avoid rejection from portals Xdg-desktop-portal will reject any OpenFile request if there is an empty filter. We will just simply skip it to avoid the rejection so users get a file dialog. Pick-to: 5.15 Change-Id: I85c056f46b22cdbc9e14010bc3c49206b6f8f002 Reviewed-by: Thiago Macieira --- .../xdgdesktopportal/qxdgdesktopportalfiledialog.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp b/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp index cf3c2c9e9b..c4dc2da623 100644 --- a/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp +++ b/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp @@ -248,6 +248,11 @@ void QXdgDesktopPortalFileDialog::openPortal() QString userVisibleName = match.captured(1); QStringList filterStrings = match.captured(2).split(QLatin1Char(' '), Qt::SkipEmptyParts); + if (filterStrings.isEmpty()) { + qWarning() << "Filter " << userVisibleName << " is empty and will be ignored."; + continue; + } + FilterConditionList filterConditions; for (const QString &filterString : filterStrings) { FilterCondition filterCondition;