Python Development : Delete Windows and Controls?
#1
Hi,

I noticed in the descriptions of the Python xbmc modules, that it is often mentioned that closing a window or removing a control, does not actually delete the window or the control.

Do I need to manually delete the windows and controls that I have created in a script or is closing the containing window enough at the end of my addon script?

How do you delete a window or control?

What about players - do you need to delete that ?

At the moment I presume that all the objects (windows, controls, players, etc) created by my script is destroyed / deleted when the script exits.
Is this correct?
Reply
#2
(2016-08-17, 16:17)jagter5 Wrote: At the moment I presume that all the objects (windows, controls, players, etc) created by my script is destroyed / deleted when the script exits.
Is this correct?

Not quite. Ideally, yes, all objects should be destroyed by the Python garbage collector when the main addon script exits. But for some reason, in Kodi SWIG-exposed C++ classes are not garbage-collected when an addon script exits. You can see in the Kodi log something like this: "the script XXX left in memory several objects: YYY, ZZZ".
My guess is that there is a bug somewhere in the reference counting mechanism for SWIG-exposed classes that prevents object's reference counter from decrementing when a SWIG-exposed object goes out of scope.

The simplest solution is to apply del operator to all instances of SWIG exposed classes, like xbmcgui.Window and such, at the end of your addon script. Contrary to a popular misconception, when applied to a separate object, the del operator does not actually delete this object but decrements its reference counter. But usually it should be enough.
Reply

Logout Mark Read Team Forum Stats Members Help
Python Development : Delete Windows and Controls?0