Minor robustness improvement of text code

Fix a potential issue reported by static analysis

Change-Id: I41b8eaa3c0840eec054e880c4f3298ee32685b46
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
This commit is contained in:
Eirik Aavitsland 2021-03-11 16:04:50 +01:00
parent 68e69588e0
commit 9fa181446c

View File

@ -240,9 +240,11 @@ QString QTextDocumentWriter::fileName () const
*/
bool QTextDocumentWriter::write(const QTextDocument *document)
{
QByteArray suffix;
if (!d->device)
return false;
if (d->device && d->format.isEmpty()) {
QByteArray suffix;
if (d->format.isEmpty()) {
// if there's no format, see if device is a file, and if so, find
// the file suffix
if (QFile *file = qobject_cast<QFile *>(d->device))