gui: Defer removeAndDeleteWallet when no modal widget is active #15614

pull promag wants to merge 1 commits into bitcoin:master from promag:2019-03-wallet-modal-widget changing 1 files +13 −1
  1. promag commented at 6:35 pm on March 17, 2019: member
    Fixes #15310.
  2. promag commented at 6:44 pm on March 17, 2019: member
  3. fanquake added the label GUI on Mar 17, 2019
  4. jonasschnelli commented at 8:06 am on March 18, 2019: contributor

    Concept ACK for 0.18.

    Looks like a hack (but a good one)… I think we should merge this into 0.18 and properly remove synchronous dialogs in 0.19.

  5. jonasschnelli added this to the milestone 0.18.0 on Mar 18, 2019
  6. jonasschnelli commented at 9:01 am on March 18, 2019: contributor

    Hmm… second thought: I’m unsure about this. This waits until the users closes the dialogs (rather then closing them explicit). This may lead to an RPC timeout in unload wallet

    Maybe we combine this with #15313?

  7. promag commented at 9:27 am on March 18, 2019: member
    I don’t think that’s a problem. The RPC client can timeout (can also happen for other reasons, rescanning for instance?) but the RPC handler still waits. This fixes a unlikely crash (I mean, is there a good reason to do this?) without major changes and can be reverted easily if the future master refactor is backport.
  8. promag commented at 7:13 pm on March 21, 2019: member
    I’ll verify if QWindow::activeChanged can be used instead of QApplication::focusChanged.
  9. MarcoFalke changed the base branch on Mar 21, 2019
  10. MarcoFalke renamed this:
    0.18: gui: Defer removeAndDeleteWallet when no modal widget is active
    gui: Defer removeAndDeleteWallet when no modal widget is active
    on Mar 21, 2019
  11. MarcoFalke commented at 7:28 pm on March 21, 2019: member
    Changed base, needs commit cherry-picked on some other base as well, obviously.
  12. promag force-pushed on Mar 21, 2019
  13. promag commented at 7:46 pm on March 21, 2019: member
    Rebased.
  14. MarcoFalke commented at 8:01 pm on March 21, 2019: member
    Should update OP with something like “Addresses #15310”?
  15. gmaxwell commented at 8:07 pm on March 21, 2019: contributor
    This seems like a better workaround to the issue for the short term.
  16. promag commented at 8:08 pm on March 21, 2019: member
    @MarcoFalke yes, after rebased with master.
  17. MarcoFalke commented at 8:14 pm on March 21, 2019: member
    tested ACK f33e9bcda8a34385872555c1857bbabdf5c68134 (No longer crashes and having the modal gui dialog open will block the unloadwallet RPC, didn’t review code too closely)
  18. DrahtBot commented at 9:37 pm on March 21, 2019: member

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

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #15478 (wip: gui: Refactor open wallet activity by promag)
    • #15204 (gui: Add Open External Wallet action by promag)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

  19. in src/qt/walletcontroller.cpp:103 in f33e9bcda8 outdated
     97@@ -97,7 +98,16 @@ WalletModel* WalletController::getOrCreateWallet(std::unique_ptr<interfaces::Wal
     98     m_wallets.push_back(wallet_model);
     99 
    100     connect(wallet_model, &WalletModel::unload, [this, wallet_model] {
    101-        removeAndDeleteWallet(wallet_model);
    102+        // Defer removeAndDeleteWallet when no modal widget is active.
    103+        if (QApplication::activeModalWidget()) {
    104+            connect(qApp, &QApplication::focusChanged, wallet_model, [this, wallet_model]() {
    


    promag commented at 10:12 pm on March 21, 2019:

    Just noting that the 3rd parameter wallet_model is used as the destination context, which means:

    • the connection is destroyed when the wallet_model is destroyed
    • the connection runs on the wallet model thread (GUI thread) due to Qt::QueuedConnection.
  20. luke-jr approved
  21. luke-jr commented at 10:35 pm on March 21, 2019: member
    I suspect there’s some race conditions here, but strict improvement over the current condition, so utACK
  22. promag commented at 0:16 am on March 22, 2019: member
    @luke-jr care to elaborate?
  23. gui: Defer removeAndDeleteWallet when no modal widget is active a10972bc03
  24. promag force-pushed on Mar 22, 2019
  25. jonasschnelli commented at 10:06 am on March 22, 2019: contributor
    Tested ACK a10972bc03e1ebbe79c3edc929c91ed53b391c9a
  26. jonasschnelli merged this on Mar 22, 2019
  27. jonasschnelli closed this on Mar 22, 2019

  28. jonasschnelli referenced this in commit abd914ed34 on Mar 22, 2019
  29. laanwj referenced this in commit b022242887 on Mar 22, 2019
  30. luke-jr commented at 3:57 pm on March 22, 2019: member

    @promag

    line 104 evaluates to false, then a problematic modal window is opened before line 111

    or

    line 104 evaluates to true, then the problematic modal window is closed before focusWindowChanged is connected; wallet closing then waits for some arbitrarily future time

  31. promag commented at 4:15 pm on March 22, 2019: member

    @luke-jr it’s impossible, both callbacks runs in the GUI thread and so:

    • first case, no modal can be opened;
    • second case, the modal can’t be closed before connecting the signal.
  32. luke-jr commented at 9:56 pm on March 22, 2019: member
    I thought the whole point of the Qt::QueuedConnection was to move the callback to the GUI thread later?
  33. luke-jr commented at 9:57 pm on March 22, 2019: member
    Ah, nevermind, I get it - the focusWindowChanged might be in another thread.
  34. PastaPastaPasta referenced this in commit 7017bc4620 on Sep 21, 2021
  35. PastaPastaPasta referenced this in commit 167363d4bd on Sep 24, 2021
  36. kittywhiskers referenced this in commit 4094e3313e on Oct 12, 2021
  37. DrahtBot locked this on Dec 16, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-12-18 18:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me