Skip to content

Conversation

@hebasto
Copy link
Member

@hebasto hebasto commented Feb 12, 2022

#336 introduced a regression when termination requests from a platform are not handled properly.

This PR fixes this regression. On macOS shutdown after clicking "Quit" in Dock icon menu, and during logout works again.

Fixes #545.

@hebasto hebasto added Bug Something isn't working UX All about "how to get things done" labels Feb 12, 2022
@hebasto hebasto added this to the 23.0 milestone Feb 12, 2022
@hebasto hebasto requested review from Sjors, jarolrod and promag February 12, 2022 16:03
@RandyMcMillan
Copy link
Contributor

tACK e7fc506

Tested on MacOS Darwin ₿ 19.6.0 Darwin Kernel Version 19.6.0: Sun Nov 14 19:58:51 PST 2021; root:xnu-6153.141.50~1/RELEASE_X86_64 x86_64

Tested on MacOS Darwin m1.deepspace.host 21.3.0 Darwin Kernel Version 21.3.0: Wed Jan 5 21:37:58 PST 2022; root:xnu-8019.80.24~20/RELEASE_ARM64_T8101 arm64

Copy link
Member

@Sjors Sjors left a comment

Choose a reason for hiding this comment

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

tACK e7fc506 (rebased on master) indeed fixes the crash described in #545


bool BitcoinApplication::event(QEvent* e)
{
if (e->type() == QEvent::Quit) {
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason QEvent::Quit is undocumented (and apparently unused in anything else Google finds)?

Copy link
Member Author

@hebasto hebasto Feb 20, 2022

Choose a reason for hiding this comment

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

I don't know. Edit: see #547 (comment)

Copy link
Member

Choose a reason for hiding this comment

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

Would be nice if there's a way we can fix this without undocumented (undefined?) behaviour.

Worst case, partially reverting #336 instead? :/

Copy link
Member Author

Choose a reason for hiding this comment

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

Is there a reason QEvent::Quit is undocumented (and apparently unused in anything else Google finds)?

Would be nice if there's a way we can fix this without undocumented (undefined?) behaviour.

Qt codease, as every other codebase, is not perfect. And if documentation diverges from code, it is an bug in documentation (https://bugreports.qt.io/browse/QTBUG-92122) which has already been fixed but not backported.

Worst case, partially reverting #336 instead? :/

Yes, this solution is also possible. Only there are two concerns:

  • do we really want to return to undocumented way to interrupt the main event loop during application run?
  • is it feasible for 23.0 considering release schedule?

Copy link
Member

Choose a reason for hiding this comment

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

it is an bug in documentation (https://bugreports.qt.io/browse/QTBUG-92122) which has already been fixed but not backported.

Ok, seems fine if that's all it is

@bitcoin-core bitcoin-core deleted a comment Feb 20, 2022
Copy link
Contributor

@promag promag left a comment

Choose a reason for hiding this comment

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

Tested ACK e7fc506 on macOS 10.15 with Qt 5.15.2.

@hebasto hebasto merged commit 00f8492 into bitcoin-core:master Feb 22, 2022
@hebasto hebasto deleted the 220212-quit branch February 22, 2022 08:36
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Feb 22, 2022
…andle QEvent::Quit

e7fc506 qt: Override BitcoinApplication::event() to handle QEvent::Quit (Hennadii Stepanov)

Pull request description:

  bitcoin-core/gui#336 introduced a regression when termination requests from a platform are not handled properly.

  This PR fixes this regression. On macOS shutdown after clicking "Quit" in Dock icon menu, and during logout works again.

  Fixes bitcoin-core/gui#545.

ACKs for top commit:
  RandyMcMillan:
    tACK e7fc506
  Sjors:
    tACK e7fc506 (rebased on master) indeed fixes the crash described in #545
  promag:
    Tested ACK e7fc506 on macOS 10.15 with Qt 5.15.2.

Tree-SHA512: 236a483dc0828f22999469e133b8ac9f0b6267ec2a27004c3ebaa967689ddb972ea1fa90c1dd41f3bff3d17bf571a707babcef53bd79fd711fda98cfbf120131
hebasto added a commit that referenced this pull request May 23, 2022
…uit()` with `QCoreApplication::exit(0)`

252f363 qt: Replace `QCoreApplication::quit()` with `QCoreApplication::exit(0)` (Hennadii Stepanov)

Pull request description:

  ### Qt 5:
   - no behavior change.

  See https://code.qt.io/cgit/qt/qtbase.git/tree/src/corelib/kernel/qcoreapplication.cpp?h=5.15#n2012:
  ```cpp
  void QCoreApplication::quit()
  {
      exit(0);
  }
  ```

  ### Qt 6:
   - this change avoids sending a duplicated `QEvent::Quit`

  We use `QEvent::Quit` to [handle](#547) macOS dock menu events. Qt 6 uses `QEvent::Quit` more [widely](qt/qtbase@89f7a27). We do not want a duplicated `QEvent::Quit` which fires `Assert(node.args);` in the [`Shutdown()`](https://github.com/bitcoin-core/gui/blob/d1b3dfb275fd98e37cfe8a0f7cea7d03595af2e8/src/init.cpp#L200) function.

ACKs for top commit:
  promag:
    Code review ACK 252f363.

Tree-SHA512: 6a04cbcf523c0375158a59b29afadf18da99738c8db8b8728f99319a8cdc10806d2f06dc5a7d3b8b0e1a5f1711be778a75d4ecdefef7cf66e26ae2848f7f57db
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Bug Something isn't working UX All about "how to get things done"

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SIGABRT on macOS after Dock menu --> Quit

5 participants