Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hard crash when using auto-hide docks in 4.2.1 #31

Open
RubendeBruin opened this issue Mar 5, 2024 · 1 comment
Open

hard crash when using auto-hide docks in 4.2.1 #31

RubendeBruin opened this issue Mar 5, 2024 · 1 comment

Comments

@RubendeBruin
Copy link

RubendeBruin commented Mar 5, 2024

The script below works fine in 4.1.0.3 but results in a "Process finished with exit code -1073741819 (0xC0000005)" after upgrading to 4.2.1 (PySide6-Essentials-6.6.2 PySide6-qtads-4.2.1 shiboken6-6.6.2)

Env:
Python 3.11
Windows 11

Not sure if this is PySide6QtAds related or QtAds. Tried to reproduce in PyQtAds but that package on pip is still at version 3.8.1 so no luck there.

"""Demo / Test file for auto hide docks in PySide6QtAds.

A custom close event is added to the docks to make them return to the hidden state when the close button is pressed.
"""

from PySide6 import QtWidgets
import PySide6QtAds

VERSION = "4.2.1"  # __version__ is not available

if VERSION == "4.2.1":
    LOCATION = PySide6QtAds.ads.SideBarLocation.SideBarRight
else:
    LOCATION = PySide6QtAds._ads.SideBarLocation.SideBarRight


def create_dock_manager(main_window):

    # auto-hide icons

    if VERSION == "4.2.1":
        # 4.2.1
        PySide6QtAds.CDockManager.setAutoHideConfigFlags(
            PySide6QtAds.ads.CDockManager.eAutoHideFlag.AutoHideSideBarsIconOnly
        )
    else:
        # < 4.2.1
        PySide6QtAds.CDockManager.setAutoHideConfigFlag(
            PySide6QtAds.CDockManager.DefaultAutoHideConfig
        )

        PySide6QtAds.CDockManager.setAutoHideConfigFlag(
            PySide6QtAds.CDockManager.AutoHideSideBarsIconOnly, True
        )

    dock_manager = PySide6QtAds.CDockManager(main_window)

    dock_manager.setConfigFlag(PySide6QtAds.CDockManager.ActiveTabHasCloseButton, False)


    return dock_manager


def set_as_central_widget(
    dock_manager: PySide6QtAds.CDockManager, widget: QtWidgets.QWidget
):
    central_dock_widget = PySide6QtAds.CDockWidget("CentralWidget")

    central_dock_widget.setWidget(widget)
    central_dock_area = dock_manager.setCentralWidget(central_dock_widget)
    central_dock_widget.setFeature(PySide6QtAds.CDockWidget.DockWidgetClosable, False)
    central_dock_area.setAllowedAreas(PySide6QtAds.DockWidgetArea.OuterDockAreas)
    return central_dock_widget

#


def _dock_return_to_hidden_state(d: PySide6QtAds.CDockWidget):
    """Triggers visibility (making it invisible) and then places it in the right sidebar."""

    d.toggleViewAction().trigger()  # removes the dock from the gui
    manager = d.dockManager()
    manager.addAutoHideDockWidget(LOCATION, d)


def add_global_dock(
    manager: PySide6QtAds.CDockManager,
    d: PySide6QtAds.CDockWidget,
):
    """Adds a dock to the manager and make it a 'global' dock.
    Global docks are docks that can not be closed and are hidden on the top right by default.
    """
    assert isinstance(d, PySide6QtAds.CDockWidget)

    #
    container = manager.addAutoHideDockWidget(
        LOCATION, d
    )
    d.setFeature(PySide6QtAds.CDockWidget.DockWidgetFeature.CustomCloseHandling, True)
    d.closeRequested.connect(lambda dock=d: _dock_return_to_hidden_state(dock))

    container.setSize(350)

    return d


if __name__ == "__main__":
    from PySide6.QtWidgets import (
        QApplication,
        QMainWindow,
        QLabel,
    )

    app = QApplication()
    mw = QMainWindow()

    dock_manager = create_dock_manager(mw)

    # create the central widget dock
    main_widget = QLabel("Main Widget")
    main_widget.setStyleSheet("background-color: lightblue;")

    central_dock = PySide6QtAds.CDockWidget("Central Dock", mw)
    central_dock.setWidget(main_widget)
    central_dock_area = dock_manager.setCentralWidget(central_dock)
    central_dock_area.setAllowedAreas(PySide6QtAds.DockWidgetArea.OuterDockAreas)

    # create an un-closable dock on the right size
    global_widget1 = QLabel("Global widget 1")
    global_widget1.setStyleSheet("background-color: lightyellow;")
    global_dock1 = PySide6QtAds.CDockWidget("Global Dock 1", mw)
    global_dock1.setWidget(global_widget1)

    d = add_global_dock(dock_manager, global_dock1)  #<-- Process finished with exit code -1073741819 (0xC0000005)

    mw.show()

    app.exec()
@RubendeBruin
Copy link
Author

Attaching the stack-trace:

Qt6Widgets!QDataWidgetMapper::toFirst:
00007ffb`530e99b0 488b01          mov     rax,qword ptr [rcx] ds:00000000`00000000=????????????????
0:000> k
 # Child-SP          RetAddr               Call Site
00 000000f3`293eef58 00007ffb`51f74383     Qt6Widgets!QDataWidgetMapper::toFirst
01 000000f3`293eef60 00007ffb`51f8941e     PySide6QtAds!PyInit_PySide6QtAds+0x5b63
02 000000f3`293eef90 00007ffb`51f09e65     PySide6QtAds!PyInit_PySide6QtAds+0x1abfe
03 000000f3`293eeff0 00007ffb`dec551d6     PySide6QtAds+0x39e65

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

No branches or pull requests

1 participant