Skip to content

Commit

Permalink
Fix segfault in test_multidemo
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreRaybaut committed Nov 7, 2024
1 parent 74dcfed commit 56a94b5
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions qwt/tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,16 @@ def __init__(self, widget_name, parent=None):
super(TestCentralWidget, self).__init__(parent)
self.widget_name = widget_name
self.plots = None
self.widget_of_interest = self.parent()
self.setLayout(QW.QVBoxLayout())
self.options = TestOptions(self)
self.add_widget(self.options)

def get_widget_of_interest(self):
"""Return widget of interest"""
if self.plots is not None and len(self.plots) == 1:
return self.plots[0]
return self.parent()

def add_widget(self, widget):
"""Add new sub-widget"""
self.layout().addWidget(widget)
Expand All @@ -257,8 +262,6 @@ def add_widget(self, widget):
plot_name, "Enable new flat style option", plot.setFlatStyle
)
widget.setChecked(plot.flatStyle())
if len(self.plots) == 1:
self.widget_of_interest = self.plots[0]


def take_screenshot(widget):
Expand Down Expand Up @@ -297,7 +300,7 @@ def test_widget(widget_class, size=None, title=None, options=True):
central_widget = TestCentralWidget(widget_name, parent=window)
central_widget.add_widget(widget)
window.setCentralWidget(central_widget)
widget_of_interest = central_widget.widget_of_interest
widget_of_interest = central_widget.get_widget_of_interest()
else:
widget_of_interest = window
widget_of_interest.setObjectName(widget_name)
Expand Down

0 comments on commit 56a94b5

Please sign in to comment.