[2.0.6] getLastMatch() returns null/None after wait/find/exists --- fixed

Bug #2008628 reported by RaiMan
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SikuliX
Fix Committed
Critical
RaiMan

Bug Description

I wanted to reuse code from another sikuli script, so I've followed your documentation about that: https://sikulix-2014.readthedocs.io/en/latest/scripting.html#importing-other-sikuli-scripts-reuse-code-and-images

And one of the prerequisites says that my imported script MUST include this for its first line:
from sikuli import *

However, when I import everything from Sikuli as requested, things didn't work as before. I've isolated the code and basically:

from Sikuli import *

wait(<some_pattern>, FOREVER)
print 'Debugging point:', getLastMatch()
click(getLastMatch())

That doesn't click anything, however, it finds the pattern but prints "Debugging point: None"

But the following two solutions work:

1. Work with the returned Match:

from Sikuli import *

click(wait(<some_pattern>, FOREVER))

2. Remove the importing line

wait(<some_pattern>, FOREVER)
click(getLastMatch())

Maybe more of a report than a question, but, is this the intended behavior? I was expecting the "getLastMatch()" to continue working as expected. Seems a little odd that stops working as before and no documentation explaining it..

Thank you in advance for this awesome tool!

--- System Info:
OS: Windows 10
Not sure what else could be helpful here

RaiMan (raimund-hocke)
Changed in sikuli:
status: New → In Progress
importance: Undecided → High
assignee: nobody → RaiMan (raimund-hocke)
milestone: none → 2.0.6
Revision history for this message
RaiMan (raimund-hocke) wrote :

tested --- works:

--- main
img = "img.png"
img1 = "img1.png"
exists(img)
print "main:", getLastMatch()
import sub
print "sub:", sub.do(img1)

--- sub:
from sikuli import *
def do(img):
    wait(img, FOREVER)
    return getLastMatch()

--- first run after IDE start
main: M[98,29 72x32]IN(0) %100,00 C(134,45) [315/314 msec]
sub: M[181,28 123x33]IN(0) %100,00 C(242,44) [282/282 msec]

--- subsequent runs in same IDE session
main: M[98,29 72x32]IN(0) %100,00 C(134,45) [6/6 msec]
sub: M[181,28 123x33]IN(0) %100,00 C(242,44) [4/4 msec]

summary: - getLastMatch() returns null/None after wait/find/exists
+ [2.0.6] getLastMatch() returns null/None after wait/find/exists ---
+ fixed
Changed in sikuli:
importance: High → Critical
RaiMan (raimund-hocke)
Changed in sikuli:
status: In Progress → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.