Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#5238 closed defect (fixed)

Restoring session with Blastresults on macOS shows Qt error

Reported by: Zach Pearson Owned by: Zach Pearson
Priority: moderate Milestone:
Component: Sequence Version:
Keywords: Cc: goddard@…, Eric Pettersen
Blocked By: Blocking:
Notify when closed: Platform: all
Project: ChimeraX

Description

When restoring a Blast session:

<QNSWindow: 0x7fe052fd40f0; contentView=<QNSView: 0x7fe052fd2dc0; QCocoaWindow(0x60000392f9c0, window=QWidgetWindow(0x600002aa4c60, name="QWidgetClassWindow"))>> has active key-value observers (KVO)! These will stop working now that the window is recreated, and will result in exceptions when the observers are removed. Break in QCocoaWindow::recreateWindowIfNeeded to debug.

is printed to the log, but the session otherwise appears to restore normally.

Attachments (1)

testblas5.cxs (2.0 MB ) - added by Zach Pearson 4 years ago.

Download all attachments as: .zip

Change History (8)

by Zach Pearson, 4 years ago

Attachment: testblas5.cxs added

comment:1 by Zach Pearson, 4 years ago

Cc: Eric Pettersen added

comment:2 by Zach Pearson, 4 years ago

Just to note: the included session file depends on the blast_qt_gui branch.

comment:3 by Tom Goddard, 4 years ago

Commenting out lines of code in BlastProteinResults shows that the following line causes the error

self.control_widget.setVisible(True)

And this widget is created earlier without a parent

self.control_widget = QWidget()

In general I always create widgets and pass in the parent. No telling what will go wrong if you don't specify a parent. For one, Qt will probably initially decide it is a top level window. The later when you put it into the layout of another window it will change its mind and recreate the window as a subwindow (as in the error message). So instead

parent = self.tool_window.ui_area
self.control_widget = QWidget(parent)

That eliminates the error. I suggest fixing all other Qt widgets you are creating so they specify their parent when created.

comment:4 by Zach Pearson, 4 years ago

Thank you so much for the debugging help! I'll incorporate the necessary changes.

in reply to:  6 comment:5 by goddard@…, 4 years ago

No trouble.  The method was to comment out all the results GUI building (no error), then add most of it back (still no error), then keep adding more and more back until I found the one line that leads to the error.  You might think that if you add widget A to the layout of widget B then B becomes the parent of A -- but that is not how Qt works.  The parent hierarchy can be anything and need not mirror which widget is laid out within which other widget -- only if you do weird stuff it often blows up.  So generally you should set the parents to mirror the layout.  If a parent is deleted then its children will be too.  If you have a weird parenting (or no parenting) then deletion does not clean up the widgets.

comment:6 by Zach Pearson, 4 years ago

Resolution: fixed
Status: assignedclosed

This commit should fix it.

comment:7 by Eric Pettersen, 4 years ago

Component: UnassignedSequence
Note: See TracTickets for help on using tickets.