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)
|
FilePath DocumentManager::getSaveAsFileName(const IDocument *document)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(document, return {});
|
QTC_ASSERT(document, return {});
|
||||||
const QString filter = allDocumentFactoryFiltersString();
|
QString filter = allDocumentFactoryFiltersString();
|
||||||
const FilePath filePath = document->filePath();
|
const FilePath filePath = document->filePath();
|
||||||
QString selectedFilter;
|
QString selectedFilter;
|
||||||
FilePath fileDialogPath = filePath;
|
FilePath fileDialogPath = filePath;
|
||||||
@@ -876,6 +876,9 @@ FilePath DocumentManager::getSaveAsFileName(const IDocument *document)
|
|||||||
if (selectedFilter.isEmpty())
|
if (selectedFilter.isEmpty())
|
||||||
selectedFilter = Utils::mimeTypeForName(document->mimeType()).filterString();
|
selectedFilter = Utils::mimeTypeForName(document->mimeType()).filterString();
|
||||||
|
|
||||||
|
if (!filter.contains(selectedFilter))
|
||||||
|
filter.prepend(selectedFilter + QLatin1String(";;"));
|
||||||
|
|
||||||
return getSaveFileName(Tr::tr("Save File As"),
|
return getSaveFileName(Tr::tr("Save File As"),
|
||||||
fileDialogPath,
|
fileDialogPath,
|
||||||
filter,
|
filter,
|
||||||
|
|||||||
Reference in New Issue
Block a user