Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cpinter
Copy link
Member

@cpinter cpinter commented Jan 25, 2023

No description provided.

Copy link
Member

@lassoan lassoan left a 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);;
Copy link
Member

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);
Copy link
Member

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);;
Copy link
Member

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).

Copy link
Member Author

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.

Copy link
Member

@lassoan lassoan Jan 28, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants