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

Fix wallet list hover crash on shutdown #765

Merged
merged 2 commits into from
Oct 16, 2023

Conversation

furszy
Copy link
Member

@furszy furszy commented Oct 6, 2023

Small follow-up to #751.

Fixes another crash cause during shutdown. Which occurs when the user hovers over the wallets list.

Future Note:
This surely happen in other places as well, we should re-work the way we connect signals. Register
lambas without any precaution can leave dangling pointers.

@DrahtBot
Copy link
Contributor

DrahtBot commented Oct 6, 2023

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK hebasto

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

@hebasto hebasto changed the title gui: fix wallet list hover crash on shutdown Fix wallet list hover crash on shutdown Oct 6, 2023
@hebasto hebasto added this to the 26.0 milestone Oct 7, 2023
@hebasto
Copy link
Member

hebasto commented Oct 7, 2023

Future Note: This surely happen in other places as well, we should re-work the way we connect signals. Register lambas without any precaution can leave dangling pointers.

Wouldn't be enough to use an QObject::connect overload with the additional context parameter, i.e.

QObject::connect(const QObject* sender, PointerToMemberFunction signal, const QObject* context, Functor functor, Qt::ConnectionType type)

instead of

QObject::connect(const QObject* sender, PointerToMemberFunction signal, Functor functor)

The former assumes that:

The connection will automatically disconnect if the sender or the context is destroyed. However, you should take care that any objects used within the functor are still alive when the signal is emitted.

Also see a discussion in #680.

@furszy furszy force-pushed the 2023_gui_fix_crash_wallet_list branch from 030cbec to 09c0c71 Compare October 13, 2023 20:36
Addressing potential crashes during shutdown. The most
noticeable one can be triggered by hovering over the
wallet list as the app shuts down.
Opening the top bar menu when the app is being destroyed
freezes the GUI shutdown process for no reason. No menu
action can be executed.

Note:
This behavior is consistent with how the tray icon menu
is cleared too.
@furszy furszy force-pushed the 2023_gui_fix_crash_wallet_list branch from 09c0c71 to 8b6470a Compare October 13, 2023 20:42
Copy link
Member Author

@furszy furszy left a comment

Choose a reason for hiding this comment

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

Future Note: This surely happen in other places as well, we should re-work the way we connect signals. Register lambas without any precaution can leave dangling pointers.

Wouldn't be enough to use an QObject::connect overload with the additional context parameter, i.e.

QObject::connect(const QObject* sender, PointerToMemberFunction signal, const QObject* context, Functor functor, Qt::ConnectionType type)

instead of

QObject::connect(const QObject* sender, PointerToMemberFunction signal, Functor functor)

The former assumes that:

The connection will automatically disconnect if the sender or the context is destroyed. However, you should take care that any objects used within the functor are still alive when the signal is emitted.

Also see a discussion in #680.

Tackled. Thanks.
I was a bit doubtful initially because we are manually deleting the wallet_controller field instead of letting QT do it for us.. but, thanks to the QObject::destroyed signal, this works fine.

Other than that, while testing the changes, I saw that the GUI shutdown process was being frozen when the user hovers over the non-triggerable top bar menu actions. So, the second commit also fixes this by clearing the menu (same as we do with the tray icon menu).

Copy link
Member

@hebasto hebasto left a comment

Choose a reason for hiding this comment

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

ACK 8b6470a, I've tested each commit separately on macOS Sonoma 14.0 (Apple M1).

src/qt/bitcoingui.cpp Show resolved Hide resolved
@hebasto hebasto merged commit 9270453 into bitcoin-core:master Oct 16, 2023
16 checks passed
@furszy furszy deleted the 2023_gui_fix_crash_wallet_list branch October 16, 2023 13:21
Frank-GER pushed a commit to syscoin/syscoin that referenced this pull request Oct 21, 2023
@hebasto
Copy link
Member

hebasto commented Oct 23, 2023

Unfortunately, it introduced a regression. See #770.

hebasto added a commit that referenced this pull request Oct 23, 2023
…actions"

f09bfab Revert "gui: provide wallet controller context to wallet actions" (Hennadii Stepanov)

Pull request description:

  The commit 7066e89 from #765 breaks "Open Wallet", "Close Wallet" and "Close All Wallets" items in the File menu (at least on Ubuntu 23.10 + Wayland).

  Reverting it to avoid this regression in the 26.0 release.

ACKs for top commit:
  furszy:
    ACK f09bfab for including it in v26.
  jarolrod:
    ACK f09bfab

Tree-SHA512: fedc621c8e9bf84a263b0c28da53225febe0267d0123830a6192297f38e40726e1613e003b634215e7d16791ba6eab52fb4baab3da9637f6660b6ae1ae98462b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants