setROI updates SCREEN --- it is not a constant content

Bug #729260 reported by Will P

This bug report was converted into a question: question #147916: setROI updates the constant variable SCREEN.

6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SikuliX
Invalid
Undecided
Unassigned

Bug Description

Calling setROI(smaller_region) changes the global variable SCREEN, which I assume is meant to be constant. The __str__ function of SCREEN also isn't updated to reflect the change.

print SCREEN
print SCREEN.getW()
setROI(Region(0,0,100,100)
print SCREEN
print SCREEN.getW()
setROI(SCREEN)

This prints out the following, and at the end the ROI is not updated to the entire screen:
Screen(0)[0,0 1440x900] E:Y, T:3.0
1440
Screen(0)[0,0 1440x900] E:Y, T:3.0
100

We can save the original parameters of SCREEN to a variable to get around this, but it took a while to figure out what was happening.

1. X 1.0 rc2
2. 64 bit Mac OSX 10.6

Revision history for this message
RaiMan (raimund-hocke) wrote :

SCREEN is a CONSTANT REFERENCE a Screen object Screen(0) and not its contents (it is a convenience).

So per definition setROI() changes the region of interest of the SCREEN object.

If you do not want this, you have to qualify your Screen/Region methods with the Screen/Region object or use with:

Revision history for this message
RaiMan (raimund-hocke) wrote :

not a bug

Changed in sikuli:
status: New → Invalid
summary: - setROI updates the constant variable SCREEN
+ setROI updates SCREEN --- it is not a constant content
Revision history for this message
RaiMan (raimund-hocke) wrote :

Update for 1st sentence in comment 1

SCREEN is a CONSTANT REFERENCE to a Screen object Screen(0) and not its contents are constant (it is a convenience).

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Related questions

Remote bug watches

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