Skip to content

make DockDrop be a non-mixin#2450

Merged
j9ac9k merged 1 commit intopyqtgraph:masterfrom
pijyoi:composition-dockdrop
Oct 26, 2022
Merged

make DockDrop be a non-mixin#2450
j9ac9k merged 1 commit intopyqtgraph:masterfrom
pijyoi:composition-dockdrop

Conversation

@pijyoi
Copy link
Copy Markdown
Contributor

@pijyoi pijyoi commented Oct 2, 2022

This is a follow-up of #2286.
Problematic areas with the previous code:

  • The DockDrop class was used as a mixin class inherited on the right-hand-side.
    • this is problematic as PyQt{5,6} (but not PySide{2,6}) supports cooperative inheritance.
  • PyQt (but not PySide) supports having virtual methods being over-ridden by a mixin class inherited on the right-hand-side
    • this can be seen in the previous code documenting this to be a "PySide bug". In fact, it is a surprising behavior of PyQt.

The above issues could perhaps be solved by inheriting DockDrop on the left-hand-side instead. But a cleaner approach seems to be to use DockDrop as a non-mixin.

@pijyoi pijyoi force-pushed the composition-dockdrop branch from c5a1530 to bfbdb75 Compare October 10, 2022 14:07
def __init__(self, allowedAreas=None):
def __init__(self, parent, allowedAreas=None):
object.__init__(self)
self.parent = parent
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @pijyoi I'm a little worried about the attribute name parent. While DockDrop does not inherit from QObject, many other objects around here do, which have a parent() and setParent() methods. Having an attribute named parent I see potentially causing confusion. I would recommend either adding parent or setParent methods, or changing the attribute name to something else that's analogous.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not satisfactory that DockDrop should hold a reference to its owner class. I was trying to eliminate this reference altogether but DropAreaOverlay needs to be provided with a parent widget.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that ROI.py has a class MouseDragHandler that serves the same purpose as this DockDrop class. Also not implemented as a mix-in.

@pijyoi pijyoi force-pushed the composition-dockdrop branch from 6d73529 to b335aca Compare October 12, 2022 12:31
@pijyoi pijyoi marked this pull request as ready for review October 12, 2022 12:49
@j9ac9k
Copy link
Copy Markdown
Member

j9ac9k commented Oct 26, 2022

This LGTM @pijyoi thanks for the PR. Always love to see if/else statements for binding specific codepaths to go away.

@j9ac9k j9ac9k merged commit d31e31b into pyqtgraph:master Oct 26, 2022
@pijyoi pijyoi deleted the composition-dockdrop branch October 26, 2022 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants