| Summary: | Krita::documents() leaks all elements when called from Python | ||
|---|---|---|---|
| Product: | [Applications] krita | Reporter: | FeepingCreature <default_357-line> |
| Component: | Scripting | Assignee: | Halla Rempt <halla> |
| Status: | ASSIGNED --- | ||
| Severity: | normal | CC: | halla |
| Priority: | NOR | ||
| Version First Reported In: | 5.2.3 | ||
| Target Milestone: | --- | ||
| Platform: | Other | ||
| OS: | Linux | ||
| Latest Commit: | Version Fixed/Implemented In: | ||
| Sentry Crash Report: | |||
|
Description
FeepingCreature
2024-11-04 20:52:06 UTC
Woops - forgot to remove the readme :) We worked around it on the Python side with this helper:
```
def acquire_elements(l: list[QOBJECT]) -> list[QOBJECT]:
# Many Pykrita functions return a `QList<QObject*>` where the objects are
# allocated for the callee. SIP does not handle this case and just leaks
# the objects outright. Fix this by taking explicit ownership of the objects.
# Note: ONLY call this if you are confident that the Pykrita function
# allocates the list members!
for obj in l:
if obj is not None:
sip.transferback(obj)
return l
```
You cannot add a QScopedPointer to a QList, but I'm trying to find alternative solutions... |