Opened 4 years ago

Last modified 4 years ago

#6450 assigned enhancement

Make open dialog modeless

Reported by: Tom Goddard Owned by: Tom Goddard
Priority: moderate Milestone:
Component: Input/Output Version:
Keywords: Cc: Eric Pettersen
Blocked By: Blocking:
Notify when closed: Platform: all
Project: ChimeraX

Description

The open file dialog is currently modal. Would be easier to use if modeless. One example I encounter sometimes is I show the Open dialog and want to find the directory of the file I am looking for. I know a related file in the the recent file history so I want to mouse over that thumbnail in the recent files, but I have to cancel the Open dialog to do that.

Another reason to use a modeless dialog is that our current modal dialog using QFileDialog.exec() runs a sub-eventloop that can lead to unexpected behavior as anything can happen via Qt events while this supposedly modal Open dialog is showing. For instance QTimer events cause redrawing. We have about 50-100 bug reports of crashes that appear to be in the Windows Open dialog with tracebacks often showing it was in the drawing code, often in a return statement or some other innocuous code. A modeless dialog may fix whatever problem is causing those many crashes.

Change History (7)

comment:1 by Tom Goddard, 4 years ago

I did an initial implementation of this using QFileDialog.show() instead of exec() and attaching a callback to the QFileDialog.finished() signal. That all worked fine and is simple.

But as usual Qt does everything wrong on the Mac. The modeless dialog floats on top of all applications (web browsers, mail client, ...). No flags (QWidget.setWindowFlags(flags)) had any effect to get it not to float on top of all applications. Also it didn't iconify when ChimeraX was iconified. So at least on Mac the modeless dialog is unusable. But the new code makes it easy to use QFileDialog.open() instead of exec() which gives a modal dialog with no sub-eventloop. This modal dialog behaves better than exec() in that it allows the ChimeraX app to be iconified when the Open dialog is shown. With exec() it is impossible to iconify the ChimeraX without first canceling the Open dialog.

I have not tried on Windows or Linux to see what the modeless dialog does, so I have not yet committed any code.

comment:2 by Tom Goddard, 4 years ago

The Mac native modeless open dialog is worse than I thought when using exec(). Although it floats on top of the main window, it stays underneath any floating tool windows. Not usable. Could file a Qt bug report.

comment:3 by Tom Goddard, 4 years ago

One of the main reasons for using exec() or a modeless open dialog was to avoid sub-eventloop processing to hopefully work-around frequent Windows crashes involving the open dialog, But it may be that updating Python from 3.9.6 to 3.9.11 has fixed that problem. Still need to wait some weeks or a month to see if the Windows crash is reported with Python 3.9.11. The new Python supposedly fixed some faulthandler signal handling problems.

comment:4 by Tom Goddard, 4 years ago

Yet another problem with exec() on the Mac -- was not able to multi-select files using shift click.

in reply to:  5 ; comment:5 by Eric Pettersen, 4 years ago

Using File→Open or "open browse" I have no trouble multi-selecting, either by mouse drag or shift-click, in both the current daily build and my personal build.  Did you mean not using exec()?

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

Yes I meant using QFileDialog.show() to run a modal open dialog without a subevent loop.  I confused it with exec() which runs with a subeventloop.

in reply to:  7 ; comment:7 by goddard@…, 4 years ago

Oops, got it wrong again.  QFileDialog.open() shows a modal dialog with no sub-eventloop.  That is the case that mode that misbehaves as described in the earlier comments.  The QFileDialog.show() method shows a modeless dialog.

Note: See TracTickets for help on using tickets.