Take Vincent's advice: using a pointer for selectedFilter

avoids a useless object creation, as Qt tolerates the
pointer to be null as well.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@39863 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Tommaso Cucinotta 2011-10-15 13:32:14 +00:00
parent c5496cbf5d
commit cb9e09f29e
2 changed files with 9 additions and 8 deletions

View File

@ -82,7 +82,7 @@ void FileDialog::setButton2(QString const & label, QString const & dir)
FileDialog::Result FileDialog::save(QString const & path,
QStringList const & filters, QString const & suggested,
QString & selectedFilter)
QString * selectedFilter)
{
LYXERR(Debug::GUI, "Select with path \"" << path
<< "\", mask \"" << filters.join(";;")
@ -95,8 +95,8 @@ FileDialog::Result FileDialog::save(QString const & path,
QString const startsWith = makeAbsPath(suggested, path);
QString const name =
QFileDialog::getSaveFileName(qApp->focusWidget(),
title_, startsWith, filters.join(";;"),
&selectedFilter, QFileDialog::DontConfirmOverwrite);
title_, startsWith, filters.join(";;"),
selectedFilter, QFileDialog::DontConfirmOverwrite);
if (name.isNull())
result.first = FileDialog::Later;
else
@ -119,7 +119,8 @@ FileDialog::Result FileDialog::save(QString const & path,
result.second = internalPath(dlg.selectedFiles()[0]);
else
result.first = FileDialog::Later;
selectedFilter = dlg.selectedNameFilter();
if (selectedFilter != 0)
*selectedFilter = dlg.selectedNameFilter();
dlg.hide();
#endif
return result;
@ -129,8 +130,7 @@ FileDialog::Result FileDialog::save(QString const & path,
FileDialog::Result FileDialog::save(QString const & path,
QStringList const & filters, QString const & suggested)
{
QString selectedFilter;
return save(path, filters, suggested, selectedFilter);
return save(path, filters, suggested, 0);
}

View File

@ -70,9 +70,10 @@ public:
Result save(QString const & path, QStringList const & filters,
QString const & suggested = QString());
/// Also retrieve the selected filter.
/// Also retrieve the selected filter (selectedFilter can be 0 if
/// that output is not needed).
Result save(QString const & path, QStringList const & filters,
QString const & suggested, QString & selectedFilter);
QString const & suggested, QString *selectedFilter);
private:
class Private;