-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Description
Short description
Calling restoreState() on a dockArea where a dock is the only object inside a container leads to the state being not correctly restored.
I don't know how it happened that a dock could appear as the only item in a container but one user managed to do that.
I couldn't find out how to trigger that.
Anyway, in that case way too many container are apoptose'd and the state is nor correctly restored
Code to reproduce
import json
import sys
import pyqtgraph as pg
from PySide6.QtWidgets import QMainWindow
from pyqtgraph.dockarea import Dock, DockArea
class DockApp(QMainWindow):
def __init__(self, title):
super().__init__()
self.dock_area = DockArea()
self.setCentralWidget(self.dock_area)
self.dock_area.addDock(Dock(name="Plot 1", closable=False), 'left')
self.dock_area.addDock(Dock(name="Plot 2", closable=False), 'left')
self.dock_area.addDock(Dock(name="Plot 4", closable=False), 'left')
self.dock_area.addDock(Dock(name="Table 1", closable=False), 'left')
self.dock_area.addDock(Dock(name="Table 2", closable=False), 'left')
self.dock_area.addDock(Dock(name="Table 3", closable=False), 'left')
state = json.loads("""{
"main": [
"vertical",
[
[
"horizontal",
[
[
"vertical",
[
[
"vertical",
[
[
"dock",
"Plot 1",
{}
]
],
{
"sizes": [
314
]
}
],
[
"dock",
"Plot 2",
{}
]
],
{
"sizes": [
314,
313
]
}
],
[
"vertical",
[
[
"dock",
"Table 3",
{}
],
[
"dock",
"Table 2",
{}
],
[
"dock",
"Table 1",
{}
]
],
{
"sizes": [
208,
207,
208
]
}
]
],
{
"sizes": [
784,
783
]
}
],
[
"dock",
"Plot 4",
{}
]
],
{
"sizes": [
631,
210
]
}
],
"float": []
}""")
self.dock_area.restoreState(state)
if __name__ == '__main__':
app = pg.Qt.mkQApp("LiveTrace")
window = DockApp(title='Test')
window.show()
sys.exit(app.exec())Expected behavior
All 6 docks should be restored like this:

Real behavior
Only 2 docks are visible. All other docks are missing.

Note: No exception is thrown
Tested environment(s)
- PyQtGraph version: 0.13.3
- Qt Python binding: PySide6 6.6.0 Qt 6.6.0
- Python version: 3.10.11 AMD64
- NumPy version: 1.26.2
- Operating system: Windows 10 22H2
- Installation method: pip
Additional context
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels