[1.0.1 ok] observe with onChange() does not work and does not run in background

Bug #1212706 reported by RaiMan on 2013-08-15
This bug affects 1 person
Affects Status Importance Assigned to Milestone

Bug Description

--- fixed in 1.0.1 per August 20 at 2 pm gmt+1
run setup again after that time to get fix

My environment is
windows xp + JRE 6 update 45
I had test the code in official document
def changed(event):
        print "something changed in ", event.region
        for ch in event.changes:
                ch.highlight() # highlight all changes
        for ch in event.changes:
                ch.highlight() # turn off the highlights
with selectRegion("select a region to observe") as r:
    # any change in r larger than 50 pixels would trigger the changed function
    onChange(50, changed)

wait(30) # another way to observe for 30 seconds

when I use old version of sikuli (1.0RC3)
everything work fine,

but when I use version 1.0.1
will always get error message
[error] script [ sikulitest ] stopped with error in line 11 <--observe(background=True)
[error] java.lang.NullPointerException ( java.lang.NullPointerException )

I also tried on windows 7 64 bit + JRE7
have the same error,

is it a bug in version 1.0.1

or observe will be use in different way in new version?

RaiMan (raimund-hocke) on 2013-08-15
Changed in sikuli:
status: New → In Progress
importance: Undecided → High
assignee: nobody → RaiMan (raimund-hocke)
milestone: none → 1.1.0
RaiMan (raimund-hocke) wrote :

... and yes, I have changed a lot with observe:
From the ChangeLog of 1.0.1

--- observe is reworked and options are added
- it is more verbose with higher debug levels

- it still stops observing after the first match (even in background with FOREVER) (not for onChange())

- if you want to run it continually, use (except onChange())
which will continue the observe after having waited the given seconds (e.g. to give time to the GUI for changes)

For all events: it is internally counted, how often the handler was visited, so it is now possible to decide in the handler wether to stop the observe after some time using e.g.
if event.getCount() > 10: event.stopObserver()
So there is no longer the need to stop the observation in the main script after some time.

... and yes: event.stopObserver() is now sufficient (instead of event.region.stopObserver() )
You still have to take care, to stop background observations at the end of the script (to be fixed with 1.1)

RaiMan (raimund-hocke) on 2013-08-20
Changed in sikuli:
status: In Progress → Fix Committed
importance: High → Critical
description: updated
summary: - [1.0.1] observe with onChange() does not work
+ [1.0.1 ok] observe with onChange() does not work and does not run in
+ background
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers