-
Notifications
You must be signed in to change notification settings - Fork 492
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
ENH: Add Python compatibility to query and retrieve widget #1064
base: master
Are you sure you want to change the base?
Conversation
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.
It looks OK but need to clarify the database object ownership.
return; | ||
} | ||
|
||
d->RetrieveDatabase = QSharedPointer<ctkDICOMDatabase>(dicomDatabase);; |
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.
extra ;
|
||
public Q_SLOTS: | ||
void setRetrieveDatabase(QSharedPointer<ctkDICOMDatabase> retrieveDatabase); | ||
void setRetrieveDatabase(ctkDICOMDatabase* dicomDatabase); |
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.
Need to describe who owns the dicomDatabase object after this call.
return; | ||
} | ||
|
||
d->RetrieveDatabase = QSharedPointer<ctkDICOMDatabase>(dicomDatabase);; |
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.
As I understand, ownership of the database is passed to this widget (the widget will delete the object when it is destroyed). This would be unexpected and have quite high chance of double-delete.
Maybe we could fix this by setting a custom deleter function that does not actually delete the object (does not do anything).
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 didn't consider this. What I'm not sure about is the reason to use a QSharedPointer in the first place. I thought about making it a simple pointer but it may break the API and didn't want to do that. Not sure what you think about this.
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.
Shared pointer makes sense because the database ownership is complicated (it may be used without a widget or used by multiple widgets) and it is very important to cleanly delete it during application exit. Unfortunately, shared pointer support has not been implemented in PythonQt, so we need workarounds.
Search for skipDelete
in this repository for how a dual mode use is inplemented in another class.
No description provided.