the portion of code that checks for a file name without extension is AFTER any warning concerning overwriting.
So, if FileBasedDocument::fileExtension is ‘.txt’, the user enters ‘dummy’ as the file name and a file ‘dummy.txt’ already exists, it is overwritten without any warning.
Moreover, I believe that it would be better to append, and not substitute, the default document extension to the name entered by the user.
Finally, the extension management could be improved. The document should have the chance to save data in different formats, hence the need to manage more than a single extension.
I would like to add that if FileBasedDocument::fileExtension and FileBasedDocument::fileWildcard were declared protected instead of private, the document could at least change them on the fly before showing the save dialog.
Of course this would still be a worse solution compared to a proper file filter management.
Yes… It does actually set the extension before showing the dialog, but if the user edits it in the dialog, then you’re right, it should ask again before overwriting it - I’ll sort that out. Ideally, the dialog would have a way to prevent the user from changing the extension, but I don’t think that’s possible on all platforms.
And yes, I know it could do with better extension support!