[1.1.0] Jython-2.7-rc3: Subclassing Region: with __init__ the java level constructors not used with super()__init__(), leaving Region "empty" --- workaround

Bug #1450354 reported by RaiMan
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SikuliX
Confirmed
High
RaiMan

Bug Description

********* workaround

setup a subclass of Region this way:

class MyRegion(Region):
    def __init__(self, x=1, y=1, w=1, h=1):
        self.setRect(x, y, w, h)

-----------------------------------------------------------

Installed nightly sikulixsetup-1.1.0-20150427.231036-54-forsetup, and my old code is breaking when I try to highlight a class that extends Region. The code worked fine with Sikuli from Dec 2014 and recently with sikulixsetup-1.1.0-20150417

Here is the simple code:
# begin code ===============================
import org.sikuli.basics.SikulixForJython
from sikuli import *

def highlight_flash(rejun, cycles=1, lightsec=1, darksec=0.25):
    if rejun != None:
        for i in range(cycles):
            rejun.highlight(lightsec)
            wait(darksec)

class SLRegion(Region):
    def __init__(self, x=1, y=1, w=1, h=1):
        super(SLRegion, self).__init__(x, y, w, h)

rejun = Region(100,100,100,100)
highlight_flash(rejun, 3)

rejun = SLRegion(100,100,100,100)
highlight_flash(rejun, 3)
# ============================================= end.

The first call to highlight_flash(...) works fine - flashes 100x100 box 3 times.
The second call fails with Null Pointer...

# begin Sikuli_IDE Log Message Window Output ==============

[log] highlight R[100,100 100x100]@S(0)[0,0 1280x1024] E:Y, T:3.0 for 1.0 secs

[log] highlight R[100,100 100x100]@S(0)[0,0 1280x1024] E:Y, T:3.0 for 1.0 secs

[log] highlight R[100,100 100x100]@S(0)[0,0 1280x1024] E:Y, T:3.0 for 1.0 secs

[log] highlight R[0,0 0x0]@Screen null E:Y, T:3.0 for 1.0 secs
[error] script [ deletelater ] stopped with error in line 18
[error] java.lang.NullPointerException ( java.lang.NullPointerException )
[error] --- Traceback --- error source first line: module ( function ) statement 7: main ( highlight_flash ) rejun.highlight(lightsec)
[error] --- Traceback --- end --------------
# end Sikuli_IDE Log Message Window Output ==============

and here is what it tells me when I run the same code in Eclipse...

# begin Eclipse Luna Error Output ==============
console: Failed to install '': java.nio.charset.UnsupportedCharsetException: cp0.
pydev debugger: starting (pid: 10232)
[log] highlight R[100,100 100x100]@S(0)[0,0 1280x1024] E:Y, T:3.0 for 1.0 secs
[log] highlight R[100,100 100x100]@S(0)[0,0 1280x1024] E:Y, T:3.0 for 1.0 secs
[log] highlight R[100,100 100x100]@S(0)[0,0 1280x1024] E:Y, T:3.0 for 1.0 secs
[log] highlight R[0,0 0x0]@Screen null E:Y, T:3.0 for 1.0 secs
Traceback (most recent call last):
  File "C:\usrbin\eclipse\plugins\org.python.pydev_4.0.0.201504132356\pysrc\pydevd.py", line 2278, in <module>
    globals = debugger.run(setup['file'], None, None)
  File "C:\usrbin\eclipse\plugins\org.python.pydev_4.0.0.201504132356\pysrc\pydevd.py", line 1704, in run
    pydev_imports.execfile(file, globals, locals) # execute the script
  File "C:\sl\bin\sikuli\deletelater.sikuli\deletelater.py", line 18, in <module>
    highlight_flash(rejun, 3)
  File "C:\sl\bin\sikuli\deletelater.sikuli\deletelater.py", line 7, in highlight_flash
    rejun.highlight(lightsec)
 at org.sikuli.util.ScreenHighlighter.captureScreen(ScreenHighlighter.java:205)
 at org.sikuli.util.ScreenHighlighter.highlight(ScreenHighlighter.java:182)
 at org.sikuli.util.ScreenHighlighter.highlight(ScreenHighlighter.java:192)
 at org.sikuli.script.Region.highlight(Region.java:2015)
 at org.sikuli.script.Region.highlight(Region.java:2043)
 at org.sikuli.script.Region.highlight(Region.java:2027)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 at java.lang.reflect.Method.invoke(Unknown Source)

java.lang.NullPointerException: java.lang.NullPointerException
# end Eclipse Luna Error Output ==============

RaiMan (raimund-hocke)
Changed in sikuli:
status: New → Confirmed
importance: Undecided → High
assignee: nobody → RaiMan (raimund-hocke)
milestone: none → 1.1.0
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.