summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/platforms/windows/qwindowsdialoghelpers.cpp')
-rw-r--r--src/plugins/platforms/windows/qwindowsdialoghelpers.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp
index 72d9d5a71b..0eab37aed2 100644
--- a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp
+++ b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp
@@ -1472,18 +1472,21 @@ public:
};
// Return the first suffix from the name filter "Foo files (*.foo;*.bar)" -> "foo".
+// Also handles the simple name filter case "*.txt" -> "txt"
static inline QString suffixFromFilter(const QString &filter)
{
- int suffixPos = filter.indexOf(QLatin1String("(*."));
+ int suffixPos = filter.indexOf(QLatin1String("*."));
if (suffixPos < 0)
return QString();
- suffixPos += 3;
+ suffixPos += 2;
int endPos = filter.indexOf(QLatin1Char(' '), suffixPos + 1);
if (endPos < 0)
endPos = filter.indexOf(QLatin1Char(';'), suffixPos + 1);
if (endPos < 0)
endPos = filter.indexOf(QLatin1Char(')'), suffixPos + 1);
- return endPos >= 0 ? filter.mid(suffixPos, endPos - suffixPos) : QString();
+ if (endPos < 0)
+ endPos = filter.size();
+ return filter.mid(suffixPos, endPos - suffixPos);
}
void QWindowsNativeSaveFileDialog::setNameFilters(const QStringList &f)