forked from qt-creator/qt-creator
Core: Fix filter when selected is not registered
Without this patch a warning will be triggered on Windows and the selected filter is not chosen on all platforms when saving a file, e.g. a json file. Change-Id: Id6de0eddcac83369596f68d50494f10b70c30b15 Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -856,7 +856,7 @@ FilePath DocumentManager::getSaveFileNameWithExtension(const QString &title, con
|
||||
FilePath DocumentManager::getSaveAsFileName(const IDocument *document)
|
||||
{
|
||||
QTC_ASSERT(document, return {});
|
||||
const QString filter = allDocumentFactoryFiltersString();
|
||||
QString filter = allDocumentFactoryFiltersString();
|
||||
const FilePath filePath = document->filePath();
|
||||
QString selectedFilter;
|
||||
FilePath fileDialogPath = filePath;
|
||||
@@ -876,6 +876,9 @@ FilePath DocumentManager::getSaveAsFileName(const IDocument *document)
|
||||
if (selectedFilter.isEmpty())
|
||||
selectedFilter = Utils::mimeTypeForName(document->mimeType()).filterString();
|
||||
|
||||
if (!filter.contains(selectedFilter))
|
||||
filter.prepend(selectedFilter + QLatin1String(";;"));
|
||||
|
||||
return getSaveFileName(Tr::tr("Save File As"),
|
||||
fileDialogPath,
|
||||
filter,
|
||||
|
||||
Reference in New Issue
Block a user