summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@digia.com>2012-10-26 08:44:00 (GMT)
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-10-31 09:34:29 (GMT)
commit015e84b8d92ea24008341bbc71b346412d52ea48 (patch)
treed26730b21401429996dbc9d6a4aa1d10927ae264 /src
parenta9dfa72fd199dd62f91764b4321df89ad02794bf (diff)
downloadQt-015e84b8d92ea24008341bbc71b346412d52ea48.zip
Qt-015e84b8d92ea24008341bbc71b346412d52ea48.tar.gz
Qt-015e84b8d92ea24008341bbc71b346412d52ea48.tar.bz2
Fix a crash in QFileDialog when selecting an invalid name filter.
When nameDetailsVisible is set to false and an invalid/empty string is passed to selectNameFilter(), the regexp used to strip the filter off the suffixes returns empty and a crash occurs. Change-Id: I926ea49514ff25a103977d8121fca1cf83d647f5 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@digia.com> Reviewed-by: Sean Harmer <sean.harmer@kdab.com> (cherry picked from qtbase/d0aa81ee104107db1ce41a9bf0f91d4cb144f7de)
Diffstat (limited to 'src')
-rw-r--r--src/gui/dialogs/qfiledialog.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/gui/dialogs/qfiledialog.cpp b/src/gui/dialogs/qfiledialog.cpp
index e7b6b22..2dd342a 100644
--- a/src/gui/dialogs/qfiledialog.cpp
+++ b/src/gui/dialogs/qfiledialog.cpp
@@ -1184,9 +1184,11 @@ void QFileDialog::selectNameFilter(const QString &filter)
d->selectNameFilter_sys(filter);
return;
}
- int i;
+ int i = -1;
if (testOption(HideNameFilterDetails)) {
- i = d->qFileDialogUi->fileTypeCombo->findText(qt_strip_filters(qt_make_filter_list(filter)).first());
+ const QStringList filters = qt_strip_filters(qt_make_filter_list(filter));
+ if (!filters.isEmpty())
+ i = d->qFileDialogUi->fileTypeCombo->findText(filters.first());
} else {
i = d->qFileDialogUi->fileTypeCombo->findText(filter);
}
@@ -1793,7 +1795,7 @@ QString QFileDialog::getOpenFileName(QWidget *parent,
// create a qt dialog
QFileDialog dialog(args);
- if (selectedFilter)
+ if (selectedFilter && !selectedFilter->isEmpty())
dialog.selectNameFilter(*selectedFilter);
if (dialog.exec() == QDialog::Accepted) {
if (selectedFilter)
@@ -1886,7 +1888,7 @@ QStringList QFileDialog::getOpenFileNames(QWidget *parent,
// create a qt dialog
QFileDialog dialog(args);
- if (selectedFilter)
+ if (selectedFilter && !selectedFilter->isEmpty())
dialog.selectNameFilter(*selectedFilter);
if (dialog.exec() == QDialog::Accepted) {
if (selectedFilter)
@@ -1981,7 +1983,7 @@ QString QFileDialog::getSaveFileName(QWidget *parent,
// create a qt dialog
QFileDialog dialog(args);
dialog.setAcceptMode(AcceptSave);
- if (selectedFilter)
+ if (selectedFilter && !selectedFilter->isEmpty())
dialog.selectNameFilter(*selectedFilter);
if (dialog.exec() == QDialog::Accepted) {
if (selectedFilter)