-
Notifications
You must be signed in to change notification settings - Fork 1k
fix(contacts): Multiple friends contacts system dependent #6621
base: master
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## master #6621 +/- ##
==========================================
- Coverage 11.75% 11.74% -0.01%
==========================================
Files 303 303
Lines 20582 20589 +7
==========================================
Hits 2419 2419
- Misses 18163 18170 +7
Continue to review full report at Codecov.
|
bodwok (2): fix(contacts): Multiple friends contacts system dependent Update contentdialogmanager.cpp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 0 of 1 LGTMs obtained
a discussion (no related file):
What's the root cause of the crash here?
It seems like on window close:
- ContentDialog::closeEvent emits willClose then accepts the event
- ContentDialogManager::addContentDialog connects ContentDialog::willClose to ContentDialogManager::onDialogClose
- ContentDialogManager::onDialogClose calls removeDialog
- contentdialogmanager.cpp's removeDialog, which deletes the ContentDialog
At some point(?) during this, the ContentDialog is destroyed by Qt due to setAttribute(Qt::WA_DeleteOnClose);
in ContentDialog's constructor.
When the second dialog is being opened, Widget::openDialog
calls Widget::addFriendDialog
which calls into ContentDialogManager to get the content dialog for the friend.
So is there a race on destruction here, that the content dialog isn't being destroyed by the time Widget tries to get the current ContentDialog? If so I think we should address the race to make sure destruction is complete rather than create invalid objects that are semi-destructed.
Changing ContentDialogManager::addContentDialog
to connect the willClose signal synchronously: connect(&dialog, &ContentDialog::willClose, this, &ContentDialogManager::onDialogClose, Qt::QueuedConnection);
seems to stop the problem on Fedora 35 - so that may be an alternative.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 0 of 1 LGTMs obtained
a discussion (no related file):
Now I found that the difference between Xorg and Wayland (Fedora) in the return value of the isActiveWindow property:
- ContentDialog::closeEvent emits willClose then accepts the event
- ContentDialogManager::addContentDialog connects ContentDialog::willClose to ContentDialogManager::onDialogClose
- ContentDialogManager::onDialogClose calls removeDialog
- contentdialogmanager.cpp's removeDialog, which deletes the ContentDialog
If we continue your call list we will get (if using Wayland):
Without this PR:
- ContentDialog::changeEvent (here
isActiveWindow() == true
and emit theactivated
signal) - ContentDialogManager::onDialogActivate (here the
currentDialog
pointer is set to the dialog that will be deleted) - ContentDialog::~ContentDialog
With this PR:
- ContentDialog::changeEvent (here
isActiveWindow() == false
) - ContentDialog::~ContentDialog
The fix you suggested works and ContentDialogManager::onDialogActivate is not called before ContentDialog::~ContentDialog
Looks like the issue related to graphics processing in Linux. On Fedora 35 it occurs if Wayland is used (setted by default). If switch to Xorg mode or run qTox with
-platform xcb
key on Fedora 35, then this error was not reproduced for me.When using Wayland, if the
ContentDialog
closes, its destructor is not called immediately, but manages to initialize thecurrentDialog
pointer inContentDialogManager::onDialogActivate
. Next theContentDialog
destructor is called, andcurrentDialog
becomes a dangling pointer.To get around this I added a flag that marks
ContentDialog
as invalid. Also another option that works for me too: useqtox -platform xcb
.Fix #6412
This change is