D6769: Proper lifetime support for one-time menu objects with contextMenuExtension

Friedrich W. H. Kossebau noreply at phabricator.kde.org
Tue Jul 18 11:56:40 UTC 2017


kossebau added a comment.


  I considered adding the QWidget parent to the KDevelop::Context class, so just one argument is passed around as before in the actual context menu content query calls.
  Decided against as that meant to me mixing of concerns, for one the object describing read-only the context in which the menu is to appear, while the parent object is to be actively used for memory management of the elements added.
  So it felt more clean to have that as explicit separate arguments in the contextMenuExtension() method, instead of having invokers of the contextmenu collection stuffing this into the context description object and providers fetching it again out of that object.
  
  Also went for QWidget as parent and not the QMenu object, even if in the current use-cases it is always the menu, because this way on the callee side it follows a usual parent type with widget classes, so common pattern, and it will avoid implementers being confused about what other things to do with the menu perhaps, when they should not and just use it for memory management purposes.

REPOSITORY
  R33 KDevPlatform

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

To: kossebau, #kdevelop
Cc: kdevelop-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20170718/39388ed7/attachment.html>


More information about the KDevelop-devel mailing list