Initialise DBus notifications in another thread #152
pull luke-jr wants to merge 1 commits into bitcoin-core:master from luke-jr:gui_notify_setup_bg changing 2 files +42 −9-
luke-jr commented at 8:38 pm on December 14, 2020: memberQDBusInterface’s constructor can hang if org.freedesktop.Notifications is missing, so avoid delaying startup waiting for a timeout
-
luke-jr force-pushed on Dec 15, 2020
-
in src/qt/notificator.cpp:44 in 0530dd0156 outdated
39+ return; 40+ } 41+ interface->moveToThread(m_notificator.thread()); 42+ m_notificator.interface = interface; 43+ m_notificator.mode = Notificator::Freedesktop; 44+}
luke-jr commented at 2:02 am on February 1, 2021:Isn’t that supposed to be an automatic part of Qt? The docs say the user can’t emit it…
icota commented at 9:52 pm on February 19, 2021:You’re right. I think it used to be public signal but seems that is no longer the case.
Talkless commented at 1:38 pm on March 13, 2021:I’d say move
m_dbus_init_thread->wait();
call into~DBusInitThread()
, so it no longer can be possible to misuse (forget). Also, connectingfinished()
signal could perform cleanup:0m_dbus_init_thread = new DBusInitThread(*this); 1connect(m_dbus_init_thread, &DBusInitThread::finished, this, [this]() { 2 m_dbus_init_thread->deleteLater(); 3 m_dbus_init_thread = nullptr; 4}); 5m_dbus_init_thread->start();
GUI: Initialise DBus notifications in another thread
QDBusInterface's constructor can hang if org.freedesktop.Notifications is missing, so avoid delaying startup waiting for a timeout
luke-jr force-pushed on Feb 1, 2021in src/qt/notificator.h:92 in a9f3096e73
88 QSystemTrayIcon *trayIcon; 89 #ifdef USE_DBUS 90+ QThread *m_dbus_init_thread{nullptr}; 91+protected: 92 QDBusInterface *interface; 93+ friend class DBusInitThread;
Talkless commented at 2:01 pm on March 13, 2021:friend
could be avoided ifDBusInitThread
would haveinterfaceCreated(QDBusInterface* interface)
signal.Signal can be invoked from within
run()
using:0QTimer::singelShot(0, this, [this, interface]() { 1 emit interfaceCreated(interface); 2});
singleShot
will detect thatthis
(context) lives in different thread and lambda will be invoked in that (receiver) context thread (whereDBusInitThread
was created).In the result,
std::atomic<Mode> mode;
“atomicity” will not be needed, because0 this->interface = interface; 1 mode = Notificator::Freedesktop;
..would be performed on thread
Notificator
lives, within a slot (or just lambda) that connected to theDBusInitThread::interfaceCreated(QDBusInterface*)
signal, and so without any race condition, as we are setting two variables, and only one is atomic.DBusInitThread
constructor will have to getQThread*
though formoveToThread().
. Or jus useDBusInitThread::thread()
to get that “destination” thread? But that’s might break ifinterface
-receiving thread is not the same that createdDBusInitThread
object…Also, adding
interface->setParent(this)
afterthis->interface = interface;
would remove need for manualdelete
, unless there’s deletion ordering is involved…Talkless commented at 2:02 pm on March 13, 2021: noneConcept ACK.DrahtBot commented at 6:27 pm on April 6, 2022: contributorThe 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 Concept ACK Talkless If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.
Conflicts
Reviewers, this pull request conflicts with the following ones:
- #686 (clang-tidy: Force checks for headers in
src/qt
by hebasto)
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.
hebasto renamed this:
GUI: Initialise DBus notifications in another thread
Initialise DBus notifications in another thread
on Apr 15, 2022hebasto commented at 9:26 pm on May 19, 2022: memberA related discussion on IRC:
<luke-jr> oh, I guess Core never merged the dbus timeout fix - that’s probably why -qt is slower <luke-jr> #152 <hebasto> luke-jr: it is not obvious that bug exist, in first place – #152 (comment) <luke-jr> hebasto: it definitely exists <hebasto> how to reproduce it reliably? <luke-jr> idk, happens every time for me <luke-jr> maybe running bitcoin-qt as another user? <hebasto> ok, could you describe your steps and observations in your PR? <luke-jr> there’s no steps, it just happens <hebasto> at least, you could mention your system on which “org.freedesktop.Notifications is missing”
DrahtBot commented at 12:27 pm on January 17, 2023: contributor🐙 This pull request conflicts with the target branch and needs rebase.
DrahtBot added the label Needs rebase on Jan 17, 2023DrahtBot commented at 0:26 am on April 17, 2023: contributorThere hasn’t been much activity lately and the patch still needs rebase. What is the status here?
- Is it still relevant? ➡️ Please solve the conflicts to make it ready for review and to ensure the CI passes.
- Is it no longer relevant? ➡️ Please close.
- Did the author lose interest or time to work on this? ➡️ Please close it and mark it ‘Up for grabs’ with the label, so that it can be picked up in the future.
hebasto commented at 4:12 pm on April 17, 2023: memberClosing this due to lack of activity. Feel free to reopen.hebasto closed this on Apr 17, 2023
bitcoin-core locked this on Apr 16, 2024
This is a metadata mirror of the GitHub repository bitcoin-core/gui. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-12-27 04:20 UTC
More mirrored repositories can be found on mirror.b10c.me