Review Request 124123: Feedback request. Problems ToolView GUI changes and ProblemModel refactoring.

Milian Wolff mail at milianw.de
Sun Jul 12 21:24:15 UTC 2015



> On July 6, 2015, 1:53 p.m., Milian Wolff wrote:
> > shell/problem.h, line 71
> > <https://git.reviewboard.kde.org/r/124123/diff/5/?file=382828#file382828line71>
> >
> >     exported classes must be pimpled
> 
> Laszlo Kis-Adam wrote:
>     The current problem implementation in the master branch isn't pimpled.
>     https://projects.kde.org/projects/extragear/kdevelop/kdevplatform/repository/revisions/master/entry/language/duchain/problem.h#L249

ok, but then please fix it while you touch it. everything that is exported must be pimpled, otherwise we never reach a status where we can update our code without breaking the ABI.


> On July 6, 2015, 1:53 p.m., Milian Wolff wrote:
> > shell/problemmodelset.h, line 33
> > <https://git.reviewboard.kde.org/r/124123/diff/5/?file=382832#file382832line33>
> >
> >     add a Q_DECLARE_TYPEINFO(ModelData, Q_MOVABLE_TYPE).
> >     
> >     also, don't export this data-only struct.
> 
> Laszlo Kis-Adam wrote:
>     Added the macro as you requested.
>     
>     As for exporting. What is your suggestion?
>     Instances of this struct is stored in the ProblemModelSet class, and when a model list is retrived using the models() method, a list is returned with instances of this struct.
>     Therefore if I don't export it, the clients cannot use the class, can they?

it's purely inline, i.e. a data-only struct. These should not be exported, and doing so can actually be harmful afaik on Windows or such. Marc Mutz would know the details, I'm just echoing from memory what I've read in some Qt code reviews of his. I'll try to find more documentation, but for now simply remove the export macro.


> On July 6, 2015, 1:53 p.m., Milian Wolff wrote:
> > shell/problemmodelset.cpp, line 37
> > <https://git.reviewboard.kde.org/r/124123/diff/5/?file=382833#file382833line37>
> >
> >     = default;
> 
> Laszlo Kis-Adam wrote:
>     In file included from /usr/include/i386-linux-gnu/qt5/QtCore/qobject.h:47:0,
>                      from /usr/include/i386-linux-gnu/qt5/QtWidgets/qwidget.h:38,
>                      from /usr/include/i386-linux-gnu/qt5/QtWidgets/QWidget:1,
>                      from /home/dfighter/build/kdevplatform/build/shell/../../src/shell/areadisplay.h:23,
>                      from /home/dfighter/build/kdevplatform/build/shell/moc_areadisplay.cpp:9,
>                      from /home/dfighter/build/kdevplatform/build/shell/KDevPlatformShell_automoc.cpp:2:
>     /usr/include/i386-linux-gnu/qt5/QtCore/qscopedpointer.h: In instantiation of ‘static void QScopedPointerDeleter<T>::cleanup(T*) [with T = KDevelop::ProblemModelSetPrivate]’:
>     /usr/include/i386-linux-gnu/qt5/QtCore/qscopedpointer.h:101:30:   required from ‘QScopedPointer<T, Cleanup>::~QScopedPointer() [with T = KDevelop::ProblemModelSetPrivate; Cleanup = QScopedPointerDeleter<KDevelop::ProblemModelSetPrivate>]’
>     /home/dfighter/build/kdevplatform/build/shell/../../src/shell/problemmodelset.h:48:5:   required from here
>     /usr/include/i386-linux-gnu/qt5/QtCore/qscopedpointer.h:51:46: error: invalid application of ‘sizeof’ to incomplete type ‘KDevelop::ProblemModelSetPrivate’
>              typedef char IsIncompleteType[ sizeof(T) ? 1 : -1 ];

don't add the `= default` to the header, keep the definition in the .cpp but `= default` it there.

    ProblemModelSet::~ProblemModelSet() = default;


> On July 6, 2015, 1:53 p.m., Milian Wolff wrote:
> > shell/problemmodelset.cpp, line 69
> > <https://git.reviewboard.kde.org/r/124123/diff/5/?file=382833#file382833line69>
> >
> >     don't return by const&
> 
> Laszlo Kis-Adam wrote:
>     Why not? It returns a reference to the container, **NOT** an element in the container.
> 
> Aleix Pol Gonzalez wrote:
>     It doesn't buy you anything and it's unsafe.
> 
> Laszlo Kis-Adam wrote:
>     Actually it does save me some resources.
>     When returning a list, the list needs to be constructed.
>     When returning a reference to that list, it's just a reference. => Faster and uses less RAM (even if in this case it's very little of a save, imagine it on a larger scale).
>     
>     As for being unsafe, explain please.
>     Obviously it can be abused (like storing the reference and dereferencing it after the list no longer exists), but **anything** can be abused.

It is not really unsafe, but it couples strongly to a data member, as you cannot return a const& to a temporary. Imagine eventually someone wants to change the implementation, now he could not as he must return a const&.

Also, your argument with returning a `const&` being faster, that is not true in most cases. Only when you also bind to a `const&` at the callee site will no copy be created, but that you could also achieve when you return a non-`const&`. NRVO or RVO and/or http://herbsutter.com/2008/01/01/gotw-88-a-candidate-for-the-most-important-const/ give you that. Thus, never return `const&`.


- Milian


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


On July 12, 2015, 8:18 p.m., Laszlo Kis-Adam wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://git.reviewboard.kde.org/r/124123/
> -----------------------------------------------------------
> 
> (Updated July 12, 2015, 8:18 p.m.)
> 
> 
> Review request for KDevelop.
> 
> 
> Repository: kdevplatform
> 
> 
> Description
> -------
> 
> Hi there!
> Here's the bottomline of what I've been doing:
> Please DO note that this is NOT done yet, I'm only submitting it to get some feedback.
> So it should NOT be merged!
> 
> (mostly)GUI changes:
> ====================
> - Moved ProblemModel to shell
> - Reworked the Problems toolview a little. Now it works like this:
> -- ProblemModels are added to ProblemModelSet.
> -- ProblemReporterFactory makes instances of ProblemsView.
> -- ProblemsView takes the models from ProblemModelSet (also subscribes for updates about them, so if one is added or removed it can add/remove their views) and it provides a tabbed widget where the views for them can be added. It creates instances of ProblemTreeView which show the problems in ProblemModel, and adds them to the tabs. Also the tabs shows the number of problems in the ProblemModels.
> -- The toolview will only add actions that are supported by the model (for example: filtering, grouping, reparsing, showing imports. Obviously reparsing doesn't make sense for runtime problem checkers)
> 
> See video:
> https://www.youtube.com/watch?v=K-wcoXcz-GM
> 
> 
> ProblemModel details:
> =====================
> - Broke up ProblemModel into 2 parts
> -- Base ProblemModel that provides the QAbstractItemModel interface for views and can use various ProblemStores to store problems. By default it uses FilteredProblemStore.
> -- ProblemReporterModel is basically the old ProblemModel that grabs problems from DUChain, it's a subclass of ProblemModel.
> - ProblemStore simply stores problems as a list (well technically it stores them in a tree, but it only has 1 level, so it's a list). There's no filtering, no grouping. It's perfect for ProblemReporterModel since it does filtering itself when grabbing the problems from DUChain.
> - FilteredProblemStore DOES filtering, and grouping itself. It stores problems in a tree (ProblemStoreNode subclasses). The tree structure depends on the grouping method, which is implemented with GroupingStrategy subclasses.
> - Moved WatchedDocumentSet and it's subclasses from ProblemModel to ProblemStore, as it is really a detail that the model itself doesn't need, however ProblemStore which stores the problems needs it actually.
> - Created a new Problem class, DetectedProblem. The intent here was to create a class with a clear interface for problems, which ProblemStore can simply store. Then I wanted to eventually replace the "old" Problem class with it. Then I realized that it's not practical because of the "show imports" feature. Which shows the problems from imported contexts. Unfortunately DUChain is the class that knows those, and it's way too much work to get it out from it. Not to mention it doesn't even make sense, since it's really something that logically belongs there. 
> Therefore my current plan now is to just bring them under a common interface so that it will not matter at all. The connection to DUchain will be hidden in the implementation.
> So the work that's left is creating this common interface and then making these two problem classes use it.
> 
> Using this new system is fairly straightforward.
> See the test plugin that I've created to test with:
> https://bitbucket.org/dfighter1985/kdev-problemtest/src
> 
> Especially widget.cpp which instantiates the model, and adds problems, or clears them based on which button is clicked.
> 
> 
> Here's a class diagram about all this:
> http://i.imgur.com/eGWR3sO.jpg
> 
> 
> Diffs
> -----
> 
>   interfaces/CMakeLists.txt 11fa364 
>   interfaces/ilanguagecontroller.h d76284c 
>   interfaces/iproblem.h PRE-CREATION 
>   language/backgroundparser/parsejob.cpp f752207 
>   language/codegen/templateengine_p.h fcb5a06 
>   language/duchain/navigation/problemnavigationcontext.h f19aa18 
>   language/duchain/navigation/problemnavigationcontext.cpp 99e2fd0 
>   language/duchain/navigation/problemnavigationcontext.cpp 99e2fd0 
>   language/duchain/problem.h eb3951a 
>   language/duchain/problem.cpp 8cbf45b 
>   language/duchain/tests/test_duchain.cpp 8d49a24 
>   plugins/problemreporter/CMakeLists.txt 39b3643 
>   plugins/problemreporter/problemhighlighter.h 1df7a79 
>   plugins/problemreporter/problemhighlighter.cpp b4a6ad2 
>   plugins/problemreporter/problemmodel.h 0d7d773 
>   plugins/problemreporter/problemmodel.cpp 9043a24 
>   plugins/problemreporter/problemreportermodel.h PRE-CREATION 
>   plugins/problemreporter/problemreportermodel.cpp PRE-CREATION 
>   plugins/problemreporter/problemreporterplugin.h 5afd8ad 
>   plugins/problemreporter/problemreporterplugin.cpp 5ca0c8d 
>   plugins/problemreporter/problemsview.h PRE-CREATION 
>   plugins/problemreporter/problemsview.cpp PRE-CREATION 
>   plugins/problemreporter/problemtreeview.h b9247d4 
>   plugins/problemreporter/problemtreeview.cpp 1c42034 
>   plugins/problemreporter/watcheddocumentset.h 9dda54d 
>   plugins/problemreporter/watcheddocumentset.cpp 143ee58 
>   shell/CMakeLists.txt cffa161 
>   shell/filteredproblemstore.h PRE-CREATION 
>   shell/filteredproblemstore.cpp PRE-CREATION 
>   shell/languagecontroller.h b9a3d06 
>   shell/languagecontroller.cpp d15a14b 
>   shell/problem.h PRE-CREATION 
>   shell/problem.cpp PRE-CREATION 
>   shell/problemmodel.h PRE-CREATION 
>   shell/problemmodel.cpp PRE-CREATION 
>   shell/problemmodelset.h PRE-CREATION 
>   shell/problemmodelset.cpp PRE-CREATION 
>   shell/problemstore.h PRE-CREATION 
>   shell/problemstore.cpp PRE-CREATION 
>   shell/problemstorenode.h PRE-CREATION 
> 
> Diff: https://git.reviewboard.kde.org/r/124123/diff/
> 
> 
> Testing
> -------
> 
> See the included video.
> 
> 
> Thanks,
> 
> Laszlo Kis-Adam
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20150712/5ae45492/attachment-0001.html>


More information about the KDevelop-devel mailing list