[Kde-graphics-devel] Review Request 127317: Don't use range-based loops with Qt containers

Daniel Vrátil dvratil at kde.org
Wed Mar 9 18:01:01 UTC 2016



> On March 9, 2016, 6:45 p.m., Kai Uwe Broulik wrote:
> > Range-for is still prefered if you can use it.
> > 
> > Just do const QList foo = foo->bar() if applicable and then you can happily use range for

> Range-for is still prefered if you can use it.

For std containers, yes. But in Qt code it's IMHO dangerous to use because seemingly harmless changes in code, like inlining your example into `for (auto baz : foo->bar())`, may trigger detach.


- Daniel


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/127317/#review93350
-----------------------------------------------------------


On March 9, 2016, 6:30 p.m., Daniel Vrátil wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://git.reviewboard.kde.org/r/127317/
> -----------------------------------------------------------
> 
> (Updated March 9, 2016, 6:30 p.m.)
> 
> 
> Review request for KDE Graphics and Boudhayan Gupta.
> 
> 
> Repository: spectacle
> 
> 
> Description
> -------
> 
> C++11 range-based loop syntax calls non-const iterators causing detach when used on Qt containers.
> 
> 
> Diffs
> -----
> 
>   CMakeLists.txt 897ba01 
>   src/CMakeLists.txt e1eb3c1 
>   src/Gui/ExportMenu.cpp 0232f4e 
>   src/Gui/ScreenClipper.cpp 4e3555b 
>   src/KipiInterface/KSGKipiImageCollectionSelector.cpp 8a5786c 
>   src/PlatformBackends/X11ImageGrabber.h e6ad26f 
>   src/PlatformBackends/X11ImageGrabber.cpp e07785a 
> 
> Diff: https://git.reviewboard.kde.org/r/127317/diff/
> 
> 
> Testing
> -------
> 
> 
> Thanks,
> 
> Daniel Vrátil
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-graphics-devel/attachments/20160309/b2a5fb94/attachment.html>


More information about the Kde-graphics-devel mailing list