nucleic / enaml

Declarative User Interfaces for Python
http://enaml.readthedocs.io/en/latest/
Other
1.52k stars 130 forks source link

Fix bug in undocking items from a tab layout #523

Closed bburan closed 1 year ago

bburan commented 1 year ago

This fixes the following error when attempting to use the mouse to undock a dock item that's part of a tab group:

Traceback (most recent call last):
  File "c:\Users\lbhb\anaconda3\envs\psi-nafc\Lib\site-packages\enaml\qt\docking\q_dock_tab_widget.py", line 350, in mouseMoveEvent
    container.untab(gpos())
                    ^^^^^^
TypeError: 'QPoint' object is not callable

I tried updating the unit-tests to catch this issue, but could not even figure out how to click on a dock item titlebar. For example, this code should work, but even during the enaml_qtbot.wait(5000), I see no evidence that item_7 was activated in the dock area (this is using the test_dock_layout.py).

        di = dock.find('item_7')
        tb = di.proxy.widget.titleBarWidget()
        title = tb._title_label
        pos = title.mapTo(tb, title.pos())
        enaml_qtbot.mouseClick(tb, Qt.LeftButton, pos=pos)
        enaml_qtbot.wait(5000)

I'm guessing if we can figure out a way to properly target one of the dock items in a tab group, then we would do mousePress followed by a mouseMove to some other area which would capture the bug.

codecov-commenter commented 1 year ago

Codecov Report

Merging #523 (21296f7) into main (b54467b) will decrease coverage by 0.04%. The diff coverage is 0.00%.

:mega: This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #523 +/- ## ========================================== - Coverage 73.42% 73.38% -0.04% ========================================== Files 296 296 Lines 26001 26001 Branches 4401 4401 ========================================== - Hits 19091 19081 -10 - Misses 5824 5831 +7 - Partials 1086 1089 +3 ```
MatthieuDartiailh commented 1 year ago

Sadly QTest is quite bugged when it comes to anything resembling a dragging operation which is what is needed here to test, so you won't be able to add a test I fear.

The changes look good to me but I wil try to dig a bit in the numerous CI failures. I missed that so many of them were systematic. Do not hesitate to ping me if I forget. I also have to deal with #480 at one point.

bburan commented 1 year ago

@MatthieuDartiailh FYI the latest release of Enaml on pypi has this bug and it causes applications to crash if the user attempts to drag a tabbed item out of a dock. Right now I'm using a custom-patched version of Enaml on all the computers I have my application installed on so it's not a high priority for me. However, I'm not sure if other users may be affected by this.

MatthieuDartiailh commented 1 year ago

I will try to merge the fix and re-release ASAP. My open source time is very limited so I won't be able to investigate the Qt issues any time soon so there is no point in delaying this fix.