Addon don't close error free (xbmcgui XML error)
#1
Hello

By disabling my addon from addon information dialog, i get this error on kodi.log:
Code:
the python script "/home/osmc/.kodi/addons/plugin.script.ibuscommunicator/service.py" has left several classes in memory that we couldn't clean up. The classes include: N14PythonBindings36XBMCAddon_xbmcgui_WindowXML_DirectorE

after enabling the addon again and opening the same window, it gets a new ID.
on leaving the window closes normally with close()

in addon shutdown i added an extra close() event. so kodi.log tells me, the window -10000 could not be located.
doModal() or show(), close() has no difference for result.

System: Rasp with OSMC

Is there a way to solve the problem?
How to find out what process let hold the window?
empty signature
Reply
#2
Nothing holds your window. My guess is that for some reason SWIG wrappers incorrectly count references for instances of some wrapped C++ classes, thus preventing Python's Garbage Collector from cleaning them. The simplest solution is to apply del operator to the problematic instances at the end of your script.
Reply
#3
i did a lot of tests.
del has no effect to release the window from kodi.
empty signature
Reply
#4
I had a simular issue when I was assigning an import to a variable. I added a variable = None before the window closes and the errors went away. For example mine was player = xxx.Player() or something similar where Player was imported from another library.
Reply
#5
further the same error. it drives me crazy...
empty signature
Reply
#6
Again, what do you mean by "release the window"? Most probably, it's incorrect reference counting issue for wrapped C++ classes.

Try to log sys.getrefcount for your problematic class instances at the end of your script to see how much references are left to your object. Ideally, it should be 2: 1 in the script main scope and 1 passed to sys.getrefcount itself. >2 will mean that there's strong chance that your object won't be cleaned.

BTW, unless overloaded, each del operator applied to an object decreases its reference counter by 1.
Reply
#7
only my window object returns: 8

in my script is no del. and i close every window dialog with close, or doModal
every thread inside are finished on exit.
empty signature
Reply
#8
(2016-12-22, 22:18)harryberlin Wrote: only my window object returns: 8

That's quite a lot. Then you need to try to decrease your object's reference counter to 0 at the end of your script and see what happens. Something like this:
Code:
try:
    while sys.getrefcount(my_object):
        del my_object
except NameError:
    pass


Quote:in my script is no del. and i close every window dialog with close, or doModal

It does not mean anything. Closing a window programmatically and garbage-collecting an unused object are two different things.
Reply
#9
the error comes always again.
empty signature
Reply
#10
this is the part of my code for the gui:

http://pastebin.com/JADA3xtM

maybe someone can see a mistake.
empty signature
Reply
#11
(2016-12-25, 12:17)harryberlin Wrote: this is the part of my code for the gui:

http://pastebin.com/JADA3xtM

maybe someone can see a mistake.

Once again (the last time): mistake is not in your code. Maybe there are some mistakes there, but they are not the source of the problem. The problem lies somewhere in the SWIG C++ wrapper implementation that prevents Python's Garbage Collector from cleaning instances of wrapped classes at the end of the main script. Applying del to explicitly set objects' reference counters to 0 usually helps but in some cases it may be not enough. In those cases troubleshooting is not a trivial task. You need to understand internal implementation of a Python interpreter, like reference counting, garbage collecting and such.
Reply
#12
(2016-12-21, 20:22)harryberlin Wrote: so kodi.log tells me, the window -10000 could not be located.

ERROR: Unable to locate window with id -10000

You get this error when you try to close not initialized window.

For example:
Code:
myWnd = myWindowXMLClass(xmlfile, path, 'Default', '')
myWnd.close()
myWnd.doModal()

In this case you will get an ERROR: Unable to locate window with id -10000

Problem can be in this place:
Code:
def obc_open_gui(self):
    # ....
    elif OBCGUI.isActive:
        OBCGUI.onStop()
        OBCGUI.show()
    # ...

About 'the python script has left several classes in memory that we couldn't clean up'. Guess: In you code you use threadung and thread.setDaemon(True). As Roman_V_M was write in other post setDaemon don't work correctly and thread will not close automatically. In onStop function or in class destructor (__del__) you must check and make sure that all threads and timers was stopped. Recommended use del for already stopped threads in order to make sure that threads will be cleaned.
Reply

Logout Mark Read Team Forum Stats Members Help
Addon don't close error free (xbmcgui XML error)0