Fix crash when accessing QFileDialog::selectedFiles() before widgets exist.
Discovered while investigating: Task-number: QTBUG-38414 Change-Id: I764195254ba4b54c86079c6e8ef750d6249960d9 Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
This commit is contained in:
parent
049fa03c2f
commit
d7d12bc1eb
@ -1,6 +1,6 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of the QtWidgets module of the Qt Toolkit.
|
||||
@ -1255,7 +1255,7 @@ QStringList QFileDialog::selectedFiles() const
|
||||
QStringList files;
|
||||
foreach (const QUrl &file, d->userSelectedFiles())
|
||||
files.append(file.toLocalFile());
|
||||
if (files.isEmpty()) {
|
||||
if (files.isEmpty() && d->usingWidgets()) {
|
||||
const FileMode fm = fileMode();
|
||||
if (fm != ExistingFile && fm != ExistingFiles)
|
||||
files.append(d->rootIndex().data(QFileSystemModel::FilePathRole).toString());
|
||||
|
@ -1,6 +1,6 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of the test suite of the Qt Toolkit.
|
||||
@ -147,6 +147,7 @@ private slots:
|
||||
void clearLineEdit();
|
||||
void enableChooseButton();
|
||||
void widgetlessNativeDialog();
|
||||
void selectedFilesWithoutWidgets();
|
||||
void trailingDotsAndSpaces();
|
||||
#ifdef Q_OS_UNIX
|
||||
#ifdef QT_BUILD_INTERNAL
|
||||
@ -1326,6 +1327,14 @@ void tst_QFiledialog::widgetlessNativeDialog()
|
||||
QVERIFY(!button);
|
||||
}
|
||||
|
||||
void tst_QFiledialog::selectedFilesWithoutWidgets()
|
||||
{
|
||||
// Test for a crash when widgets are not instantiated yet.
|
||||
QFileDialog fd;
|
||||
fd.setAcceptMode(QFileDialog::AcceptOpen);
|
||||
QVERIFY(fd.selectedFiles().size() >= 0);
|
||||
}
|
||||
|
||||
void tst_QFiledialog::trailingDotsAndSpaces()
|
||||
{
|
||||
#ifndef Q_OS_WIN
|
||||
|
Loading…
Reference in New Issue
Block a user