[Development] Module maintainers: please prepare for [[nodiscard]] QFile::open

Giuseppe D'Angelo giuseppe.dangelo at kdab.com
Wed Apr 17 20:37:23 CEST 2024


Hi,

> https://codereview.qt-project.org/c/qt/qtbase/+/550842

has just been merged.

TL;DR: this patch will make QFile::open [[nodiscard]] by default 
starting from Qt 6.10 (*).

While there's some time before that happens, it also means that as soon 
as the Qt version is bumped to 6.10 in dev, your code will raise 
warnings (or, under -Werror / developer builds, it will stop compiling) 
if you call QFile::open() and ignore the return value.

Please prepare your modules in advance: build Qt with 
`-DQT_USE_NODISCARD_FILE_OPEN` in CXXFLAGS (or use any equivalent way to 
add that define globally) and fix any raised warnings or errors.

I've already cleaned up qtdeclarative, its dependencies, and qttools.


(*) However, we could also *not* wait for the automatic switch, and add 
this define to the defines always set when building Qt itself. I'm a bit 
torn on the timing here.


Thank you,
-- 
Giuseppe D'Angelo | giuseppe.dangelo at kdab.com | Senior Software Engineer
KDAB (France) S.A.S., a KDAB Group company
Tel. France +33 (0)4 90 84 08 53, http://www.kdab.com
KDAB - Trusted Software Excellence
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4244 bytes
Desc: Firma crittografica S/MIME
URL: <http://lists.qt-project.org/pipermail/development/attachments/20240417/e72969ff/attachment.bin>


More information about the Development mailing list