-
-
Notifications
You must be signed in to change notification settings - Fork 419
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
Refactor qt notification and its test solve problem of segfaults #5138
Refactor qt notification and its test solve problem of segfaults #5138
Conversation
Codecov Report
@@ Coverage Diff @@
## main #5138 +/- ##
==========================================
+ Coverage 87.62% 87.79% +0.17%
==========================================
Files 587 578 -9
Lines 50051 49432 -619
==========================================
- Hits 43855 43398 -457
+ Misses 6196 6034 -162
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
failing is unrelated and connected with lack of remote resources required by the briefcase. |
Click here to download the docs artifacts |
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.
I don't understand this yet, but that doesn't mean it's not a good idea. If you can help clarify some of my questions and misunderstanding, can definitely switch to approval. Or maybe @Carreau has a better idea here.
@@ -436,3 +405,32 @@ def _debug_tb(tb): | |||
print("Entering debugger. Type 'q' to return to napari.\n") | |||
pdb.post_mortem(tb) | |||
print("\nDebugging finished. Napari active again.") | |||
|
|||
|
|||
class TracebackDialog(QDialog): |
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.
Is there any benefit to having the new dialog type TracebackDialog
? It doesn't expose any new public attributes or methods and I think the behavior is the same (i.e. the code here is mostly the same, just swapping self
with tbdialog
.
I don't feel strongly here, but just wanted to check I understood the changes.
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.
Oh, is it so you can patch it specifically in the test?
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.
There are three reasons:
The Main is to change _enter_debug_mode
into the method that is better for not leak memory.
The second one you mention: More specific patching.
And for last it looks better for me.
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.
That works.
@@ -358,38 +358,7 @@ def from_notification( | |||
if isinstance(notification, ErrorNotification): | |||
|
|||
def show_tb(parent_): |
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.
Not directly related to these changes, but should the typing of ActionSequence
be updated that each action callable associated with a NapariQtNotification
passes through the parent (i.e. a QWidget
) as the only argument?
I bring this up because I was confused about how the parent actually gets passed through. Is my understanding correct? That is occurs when the action callable is executed? And the parent is the same as the parent of the original notification (likely mainwindow or some main widget in napari)?
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.
I have fixed ActionSequence
definition. I'm not sure what the general idea for this mechanism was introduced by @Carreau.
My first idea is that it is introduced to manipulate NapariQtNotification
but it is closed by the same event. So maybe it should just pass the parent object.
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.
Might be a good idea to rename parent_
? If I followed the existing logic properly here (and it's possible that I didn't!), then this will always be an instance of NapariQtNotification
. In some sense that's the parent dialog of the dialog created here, but not in the sense of the QObject
parent/child hierarchy.
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.
Done
widget = QWidget() | ||
qtbot.add_widget(widget) | ||
|
||
dialog = NapariQtNotification.from_notification(notif, parent=widget) |
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.
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.
The NapariQtNotification
dialog doe not need to have a set parent, as it could be handled by qtbot
, but without this, I do not know how to handle TracebackDialog
to be guarded by qtbot
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.
Ah, I get it, the Qt parent hierarchy is:
QWidget
NapariQtNotification
TracebackDialog
Previously, we just tracked the instance of NapariQtNotification
, which didn't have a parent, but that means TracebackDialog
wasn't tracked by qtbot. So parent
here is representing some main widget or window in napari.
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.
Yes
Click here to download the docs artifacts |
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.
Looks good to me, but it's probably worth @Carreau taking a look too.
Click here to download the docs artifacts |
Click here to download the docs artifacts |
* refactor qt notification and its test to hopefully solve problem of segfaults * update mocking * fix ActionSequence definition * update `show_tb` argument name * add information about current qtbot guard structure to comment
* refactor qt notification and its test to hopefully solve problem of segfaults * update mocking * fix ActionSequence definition * update `show_tb` argument name * add information about current qtbot guard structure to comment
* refactor qt notification and its test to hopefully solve problem of segfaults * update mocking * fix ActionSequence definition * update `show_tb` argument name * add information about current qtbot guard structure to comment
* refactor qt notification and its test to hopefully solve problem of segfaults * update mocking * fix ActionSequence definition * update `show_tb` argument name * add information about current qtbot guard structure to comment
* refactor qt notification and its test to hopefully solve problem of segfaults * update mocking * fix ActionSequence definition * update `show_tb` argument name * add information about current qtbot guard structure to comment
* refactor qt notification and its test to hopefully solve problem of segfaults * update mocking * fix ActionSequence definition * update `show_tb` argument name * add information about current qtbot guard structure to comment
* refactor qt notification and its test to hopefully solve problem of segfaults * update mocking * fix ActionSequence definition * update `show_tb` argument name * add information about current qtbot guard structure to comment
Description
During investigate why the qt notifications test fails with segfaults, I found that there exists Qdialog that is created without setting Parent that may cause segfaults (this is my assumption)
Type of change
References
Try to fix segfaults showed in #5137
How has this been tested?
as there are small differences between the two Qt bindings.
Final checklist:
trans.
to make them localizable.For more information see our translations guide.