Review Request 121263: Prevent API abuse of calling setters on temporary objects.
Milian Wolff
mail at milianw.de
Thu Nov 27 00:43:14 UTC 2014
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/121263/
-----------------------------------------------------------
Review request for KDE Frameworks, Christoph Cullmann, Dominik Haumann, and Kevin Funk.
Repository: ktexteditor
Description
-------
In KDevelop we currently hit this often since our old class
previously returned a reference for the start/end getters of range
and cursor. With the help of C++11 ref qualifiers, we can detect that
and let the compiler give the user an error message:
error: cannot initialize object parameter of type 'KTextEditor::Cursor'
with an expression of type 'KTextEditor::Cursor'
documentRange().start().setColumn(42);
^~~~~~~~~~~~~~~~~~~~~~~
Yes, the error message is pretty bad. But better than nothing? We
could also mark the && overloads of these functions as explictily
deleted, which would slightly improve the error message...
Diffs
-----
src/include/CMakeLists.txt 94b8e79e2f2b273ec344a963ba6ac81ec5a481c6
src/include/ktexteditor/cursor.h 4ebe38fc1bffb2dad02150884fd225fe3ca9e193
src/include/ktexteditor/global.h PRE-CREATION
src/include/ktexteditor/range.h 1a2fc5b200c70364c3d99223e43a2ad6179055de
Diff: https://git.reviewboard.kde.org/r/121263/diff/
Testing
-------
Thanks,
Milian Wolff
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20141127/05474c68/attachment.html>
More information about the Kde-frameworks-devel
mailing list