D24046: Allow triggering sort from QML

Michael Pyne noreply at phabricator.kde.org
Sun Nov 24 19:07:49 GMT 2019


mpyne added inline comments.

INLINE COMMENTS

> broulik wrote in personssortfilterproxymodel.h:53
> "You can ... reimplement virtual functions defined in the primary base class hierarchy (that is, virtuals defined in the first non-virtual base class, or in that class's first non-virtual base class, and so forth) if it is safe that programs linked with the prior version of the library call the implementation in the base class rather than the derived one. This is tricky and might be dangerous. Think twice before doing it. Alternatively see below for a workaround."
> Now I'm confused :(

Approximately no one uses C++ virtual classes (which are a separate feature from virtual methods which we are used to).

Basically, reimplementing a virtual function that's already defined in a base class can be binary compatible for already-compiled programs because it doesn't change the size or calling convention of the virtual table: there was already a slot in the virtual table to call the base class's implementation of a virtual function, and we replaced the pointer in the virtual table to instead call the newly-implemented virtual function in the derived class.

The catch is that already-compiled code is not guaranteed to call the derived class implementation (due to inlining or other optimizations, for instance) so you cannot absolutely rely on your new implementation being called.

If you have to think too hard about whether it's safe or not, it's best to assume it's not.

In this case we're literally just calling the original implementation anyways, and `Q_INVOKABLE` is just to register it to the meta-object system, so I think this should be fine. But if we want to use a separate method I'd label it as "KF6 TODO" or something similar so that we can go back and fix it up.

REPOSITORY
  R307 KPeople

REVISION DETAIL
  https://phabricator.kde.org/D24046

To: nicolasfella, apol
Cc: mpyne, jbbgameich, broulik, kde-frameworks-devel, LeGast00n, GB_2, michaelh, ngraham, bruns
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20191124/adf98b1e/attachment.html>


More information about the Kde-frameworks-devel mailing list