...acces violation....
#1
i try to work on an addon,...

i need some information about the selectedItem
from a list constructed by python,...

but i have got an error:

Code:
EXCEPTION: access_voilation
09:11:38 T:3728   ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                                             - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                            Error Type: <type 'exceptions.RuntimeError'>
                                            Error Contents: access_voilation
                                            Traceback (most recent call last):
                                              File "C:\Users\ALAMATA\AppData\Roaming\XBMC\addons\plugin.video.dinotube\addon.py", line 152, in <module>
                                                print (xbmcgui.Window(xbmcgui.getCurrentWindowId()).getFocus().getSelectedItem())
                                            RuntimeError: access_voilation
                                            -->End of Python script error report<--

as you can see , i use this:

Code:
xbmcgui.Window(xbmcgui.getCurrentWindowId()).getFocus().getSelectedItem()

i dont understand why i have the "acces violation" error,...

sample code :

Code:
def show_categories():
                .......
               for q, a in zip(cattitle, search):
            
                
                 addDir('{0}'.format(q, a), '{1}'.format(q, a), icon)


xbmcplugin.endOfDirectory(int(sys.argv[1]))
print (xbmcgui.Window(xbmcgui.getCurrentWindowId()).getFocus().getSelectedItem())


how can bypass the problem,...

what is the solution to get the selectedItem from a list constructed by python,...Huh

is there an alternative to make that possible,...

sorry for my ignorance,...
Reply
#2
I seem to recall a similar issue.

try breaking apart the call.

PHP Code:
win xbmcgui.Window(xbmcgui.getCurrentWindowId())
ctl win.getFocus()
itm ctl.getSelectedItem() 

also make sure the focused control is a list control.
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#3
hey Nuka1195,

first thx for your intervention,..

i dont have no more acces violation error,... Wink

but it 's return now : NONE...Confused

here a sample of the code used:

Code:
for q, a in zip(cattitle, search):
            
                
                 addDir('{0}'.format(q, a), '{1}'.format(q, a), icon)
                 win = xbmcgui.Window(xbmcgui.getCurrentWindowId())
                 ctlL = win.getFocusId()
                 print(str(ctlL))
                 itm = win.getControl(ctlL).getSelectedItem()
                 print ('firstattempt   '+ str(itm))

if True:
    xbmcplugin.endOfDirectory(int(sys.argv[1]))
win = xbmcgui.Window(xbmcgui.getCurrentWindowId())
ctl = win.getFocus()
curctl= win.getControl(52)
itm = curctl.getSelectedItem()
print (str (win))
print (str (ctl))    
print (secondattempt   '+ str(itm))

here is the log,...

Code:
...
...
...
DEBUG: NEWADDON PythonCallbackHandler construction with PyThreadState 0xce98c10
NOTICE: 52
NOTICE: firstattempt     None

...
...
...

NOTICE: <xbmcgui.Window object at 0x0EF1E920>
NOTICE: <xbmcgui.Control object at 0x0D74AF08>
NOTICE: secondattempt   None

do i make something wrong,...??

is there a solution to make the "getselectedItem()" possible,....Huh

thx for your comprehension,...
Reply
#4
Xbmc may not allow python to access media windows lists. It would be a useful feature.

You may have to use infolabels for your needs.
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#5
(2012-12-07, 21:29)Nuka1195 Wrote: Xbmc may not allow python to access media windows lists. It would be a useful feature.

+10


(2012-12-07, 21:29)Nuka1195 Wrote: You may have to use infolabels for your needs.

it' s PERFECT....Big GrinBig Grin

thx a lot for this precious information,...NodNod

here the code i use now,...

Code:
pos=int(xbmc.getInfoLabel("Container.Position"))-1

rem:

it give the position in the "previous " concerned control so i have adapted my code,...

thx for your patience,... Wink
Reply
#6
...

after testing deeper the code,....


the ""Container.Position"" give only the position of the visible items,...

if you have a max of 15 items per page,
even if you are in the second page
it will return you a number <=15

not the "absolute position"

so i have bypass this lack
with this sort of code

Code:
c=0
            for q, a in zip(cattitle, search):
                 c=c+1
                 addDir(str(c)+"."+'{0}'.format(q, a), icon,)


......
.....
.....

                listlabel=str(xbmc.getInfoLabel("Listitem.Label"))
        print listlabel
        pointposition=listlabel.index(".")
        pos=int(listlabel[:pointposition])-1
                print search[pos]


Voila,....
Reply

Logout Mark Read Team Forum Stats Members Help
...acces violation....0