Are control objects no longer static in Matrix?
#1
Attempting to get the control of a radio button via getFocus() when a button is pressed triggered by the onAction function. The object of an individual radio button (xbmcgui.ControlRadioButton object at 0x0000025E4F076780) seems to be always changing when calling getFocus. 

The getFocusId() function works as it did in Kodi 18, providing the same control ID no matter how many times it's called on the same button.
Reply
#2
That's a memory address not a control id. I can't speculate on why you see this value over the control Id until code is provided.
Image Lunatixz - Kodi / Beta repository
Image PseudoTV - Forum | Website | Youtube | Help?
Reply
#3
(2021-05-22, 08:02)Lunatixz Wrote: That's a memory address not a control id. I can't speculate on why you see this value over the control Id until code is provided.

Hey Lunatixc, I referred to getFocusId() as an example of a function that is working the same in Matrix as it did in Leia. My is issue is that the function getFocus() is issuing different controls each time it is called on the same button.
python:

def onAction(self, action):
    y = self.getFocus()
    x = self.getFocus()

    if y == x:
        xbmc.log('are equal', xbmc.LOGERROR)
    else:
        xbmc.log('are not equal', xbmc.LOGERROR)

The result will be "are not equal" in Matrix and "are equal" in Leia.
Reply
#4
(2021-05-22, 09:10)SEIKT Wrote:
(2021-05-22, 08:02)Lunatixz Wrote: That's a memory address not a control id. I can't speculate on why you see this value over the control Id until code is provided.

Hey Lunatixc, I referred to getFocusId() as an example of a function that is working the same in Matrix as it did in Leia. My is issue is that the callback function getFocus() is issuing different controls each time it is called on the same button.
python:

def onAction(self, action):
    y = self.getFocus()
    x = self.getFocus()

    if y == x:
        xbmc.log('are equal', xbmc.LOGERROR)
    else:
        xbmc.log('are not equal', xbmc.LOGERROR)

The result will be "are not equal" in Matrix and "are equal" in Leia.

I suggest you include more prints during your debug like the actual control id... Chances are you are unknowingly changing focus.
Image Lunatixz - Kodi / Beta repository
Image PseudoTV - Forum | Website | Youtube | Help?
Reply
#5
(2021-05-22, 09:52)Lunatixz Wrote:
(2021-05-22, 09:10)SEIKT Wrote:
(2021-05-22, 08:02)Lunatixz Wrote: That's a memory address not a control id. I can't speculate on why you see this value over the control Id until code is provided.

Hey Lunatixc, I referred to getFocusId() as an example of a function that is working the same in Matrix as it did in Leia. My is issue is that the callback function getFocus() is issuing different controls each time it is called on the same button.
python:

def onAction(self, action):
    y = self.getFocus()
    x = self.getFocus()

    if y == x:
        xbmc.log('are equal', xbmc.LOGERROR)
    else:
        xbmc.log('are not equal', xbmc.LOGERROR)

The result will be "are not equal" in Matrix and "are equal" in Leia.

I suggest you include more prints during your debug like the actual control id... Chances are you are unknowingly changing focus.

python:

def onAction(self, action):
    y = self.getFocus()
    x = self.getFocus()

    yId = y.getId()
    xId = x.getId()

    xbmc.log('the y control id is ' + str(yId), xbmc.LOGERROR)
    xbmc.log('the x control id is ' + str(xId), xbmc.LOGERROR)
    xbmc.log('the control id is ' + str(self.getFocusId() ), xbmc.LOGERROR)
    xbmc.log('the control id is ' + str(self.getFocusId() ), xbmc.LOGERROR)

    if y == x:
        xbmc.log('controls are equal', xbmc.LOGERROR)
    else:
        xbmc.log('controls are not equal', xbmc.LOGERROR)
        
    if yId == xId:
        xbmc.log('control ID\'s are equal', xbmc.LOGERROR)
    else:
        xbmc.log('control ID\'s are not equal', xbmc.LOGERROR)

Results:

Matrix:
the y control id is 3035
the x control id is 3035
the control id is 3035
the control id is 3035
controls are not equal
control ID's are equal

Leia:
the y control id is 3068
the x control id is 3068
the control id is 3068
the control id is 3068
controls are equal
control ID's are equal
Reply
#6
you would need to use a debugger to check the threads, but there are many of these python bugs like the strptime bug that has been in kodi for 10 years. something to do with CAPI modules and the python init process.
Reply
#7
(2021-05-22, 10:54)SEIKT Wrote:
(2021-05-22, 09:52)Lunatixz Wrote:
(2021-05-22, 09:10)SEIKT Wrote: Hey Lunatixc, I referred to getFocusId() as an example of a function that is working the same in Matrix as it did in Leia. My is issue is that the callback function getFocus() is issuing different controls each time it is called on the same button.
python:

def onAction(self, action):
    y = self.getFocus()
    x = self.getFocus()

    if y == x:
        xbmc.log('are equal', xbmc.LOGERROR)
    else:
        xbmc.log('are not equal', xbmc.LOGERROR)

The result will be "are not equal" in Matrix and "are equal" in Leia.

I suggest you include more prints during your debug like the actual control id... Chances are you are unknowingly changing focus.

python:

def onAction(self, action):
    y = self.getFocus()
    x = self.getFocus()

    yId = y.getId()
    xId = x.getId()

    xbmc.log('the y control id is ' + str(yId), xbmc.LOGERROR)
    xbmc.log('the x control id is ' + str(xId), xbmc.LOGERROR)
    xbmc.log('the control id is ' + str(self.getFocusId() ), xbmc.LOGERROR)
    xbmc.log('the control id is ' + str(self.getFocusId() ), xbmc.LOGERROR)

    if y == x:
        xbmc.log('controls are equal', xbmc.LOGERROR)
    else:
        xbmc.log('controls are not equal', xbmc.LOGERROR)
        
    if yId == xId:
        xbmc.log('control ID\'s are equal', xbmc.LOGERROR)
    else:
        xbmc.log('control ID\'s are not equal', xbmc.LOGERROR)

Results:

Matrix:
the y control id is 3035
the x control id is 3035
the control id is 3035
the control id is 3035
controls are not equal
control ID's are equal

Leia:
the y control id is 3068
the x control id is 3068
the control id is 3068
the control id is 3068
controls are equal
control ID's are equal
That's an odd one... however, it's a memory address that shouldn't be used operationally. Compare by control id...
Image Lunatixz - Kodi / Beta repository
Image PseudoTV - Forum | Website | Youtube | Help?
Reply
#8
Thanks for your help fellas, I think someone made changes to controls in Matrix as they longer accept floats, they must be integers only. They may have created a bug. Anyway, I'll use control ID's instead, not sure why I preferred controls over ID's, the only thing that comes to mind is speed as getting the control ID from a control adds an extra step. Hopefully the transition to control ID's doesn't cause me any issues.
Reply
#9
Yes controls comparison was broken in Matrix. You should compare their IDs.
Reply

Logout Mark Read Team Forum Stats Members Help
Are control objects no longer static in Matrix?0