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

BUG: avoid app freeze on mac #983

Merged
merged 3 commits into from
Jul 16, 2021
Merged

BUG: avoid app freeze on mac #983

merged 3 commits into from
Jul 16, 2021

Conversation

pieper
Copy link
Member

@pieper pieper commented Jul 15, 2021

After recent changes to allow native file browsers,
clicking the button would apparently create a dialog
on mac but it was not visible. Because it was modal
the app would be alive but unresponive.

This change replaces show() and raise() which work
for QDialog with exec() which is apparently needed
for the native dialog to work properly.

https://discourse.slicer.org/t/slicer-is-freezing-on-macos-when-clicking-on-import-dicom-files/18624

Co-authored-by: Andras Lasso lasso@queensu.ca

pieper and others added 2 commits July 15, 2021 13:58
After recent changes to allow native file browsers,
clicking the button would apparently create a dialog
on mac but it was not visible.  Because it was modal
the app would be alive but unresponive.

This change replaces show() and raise() which work
for QDialog with exec() which is apparently needed
for the native dialog to work properly.

https://discourse.slicer.org/t/slicer-is-freezing-on-macos-when-clicking-on-import-dicom-files/18624

Co-authored-by: Andras Lasso <lasso@queensu.ca>
Copy link
Member

@lassoan lassoan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Raise+show was an undocumented way of displaying a popup, so it is better to switch to exec.

@lassoan
Copy link
Member

lassoan commented Jul 16, 2021

We could probably don't need this->ImportDialog->setWindowModality(Qt::ApplicationModal); (I think this is the default for modal popups already).

We may also consider using exec() for the query popup, too (instead of raise+show).

@pieper
Copy link
Member Author

pieper commented Jul 16, 2021

We could probably don't need this->ImportDialog->setWindowModality(Qt::ApplicationModal); (I think this is the default for modal popups already).

At least with raise and show this change made the dialog appear, but you could still click on buttons and interact with the app even though the dialog remained on top, so very unconventional behavior.

We may also consider using exec() for the query popup, too (instead of raise+show).

I never saw bad behavior with that one, probably because it's a non-native dialog, so I left it as-is.

@lassoan
Copy link
Member

lassoan commented Jul 16, 2021

I never saw bad behavior with that one, probably because it's a non-native dialog, so I left it as-is.

OK. Maybe just add a comment there, that exec may work better if issues are observed (appears on the wrong monitor, etc.).

@jamesobutler
Copy link
Contributor

jamesobutler commented Jul 16, 2021

May want to already begin using open() over exec(). The note in the documentation says

Note: Avoid using this function; instead, use open(). Unlike exec(), open() is asynchronous, and does not spin an additional event loop. This prevents a series of dangerous bugs from happening (e.g. deleting the dialog's parent while the dialog is open via exec()). When using open() you can connect to the finished() signal of QDialog to be notified when the dialog is closed.

https://doc.qt.io/qt-5/qdialog.html#exec
https://doc.qt.io/qt-5/qdialog.html#open

@pieper
Copy link
Member Author

pieper commented Jul 16, 2021

May want to already begin using open() over exec().

This behaves the same as raise() and show() (at least on mac with current Qt). Probably because it's a native dialog so let's stick with exec for now.

It turns out ctkDICOMQueryRetrieveWidget is a QWidget not a QDialog so it doesn't have an exec().

So I think we're good with this and ready to merge.

@lassoan
Copy link
Member

lassoan commented Jul 16, 2021

I agree, the current content of the PR looks good to me.

@pieper pieper merged commit 693c99a into commontk:master Jul 16, 2021
@pieper pieper deleted the 982-mac-freeze branch July 16, 2021 17:47
pieper added a commit to Slicer/Slicer that referenced this pull request Jul 16, 2021
pieper added a commit to Slicer/Slicer that referenced this pull request Jul 16, 2021
commontk/CTK#983

Closes #5739

CTK:
$ git shortlog --no-merges a964dcc..693c99a
Steve Pieper (3):
      BUG: avoid app freeze on mac
      SYTLE: remove dead code
      STYLE: add comment about QWidget
sjh26 added a commit to KitwareMedical/Slicer that referenced this pull request Feb 10, 2022
commontk/CTK#983

Closes #5739

CTK:
$ git shortlog --no-merges a964dcc..693c99a
Steve Pieper (3):
      BUG: avoid app freeze on mac
      SYTLE: remove dead code
      STYLE: add comment about QWidget
jcfr pushed a commit to NousNav/Slicer that referenced this pull request Mar 9, 2022
commontk/CTK#983

Closes Slicer#5739

CTK:
$ git shortlog --no-merges a964dcc..693c99a
Steve Pieper (3):
      BUG: avoid app freeze on mac
      SYTLE: remove dead code
      STYLE: add comment about QWidget
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants