QSaveFile: code tidies

Turn a cast into a call to QFlags::toInt(), plus a cast.

This is in preparation for a future patch that will remove the
implicit conversion. So why not casting directly? Because we don't
know if the QFlags is backed by int or uint, so using the wrong
cast won't compile; and we MUST pass unsigned because of the %x
specifier. Granted, one could've used a static_assert, but I prefer
a more flexible and idiomatic solution.

Change-Id: I32a3e0ed69b925e8d56268ec84d9e668ca540188
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Giuseppe D'Angelo 2021-05-02 02:27:51 +02:00
parent 97228214bd
commit 5a1c3c29ac

View File

@ -204,7 +204,7 @@ bool QSaveFile::open(OpenMode mode)
// In the future we could implement ReadWrite by copying from the existing file to the temp file...
// The implications of NewOnly and ExistingOnly when used with QSaveFile need to be considered carefully...
if (mode & (ReadOnly | Append | NewOnly | ExistingOnly)) {
qWarning("QSaveFile::open: Unsupported open mode 0x%x", int(mode));
qWarning("QSaveFile::open: Unsupported open mode 0x%x", uint(mode.toInt()));
return false;
}