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

Kai Uwe Broulik kde at privat.broulik.de
Wed Mar 9 18:05:19 UTC 2016



> On März 9, 2016, 5:45 nachm., 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
> 
> Daniel Vrátil wrote:
>     > 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.

Perhaps... still I would not want to use qforeach if not neccessary


- Kai Uwe


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


On März 9, 2016, 5:30 nachm., Daniel Vrátil wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://git.reviewboard.kde.org/r/127317/
> -----------------------------------------------------------
> 
> (Updated März 9, 2016, 5:30 nachm.)
> 
> 
> 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/e1311549/attachment-0001.html>


More information about the Kde-graphics-devel mailing list