Author Topic: MacOSX 10.7.5 graphics.end() problem?  (Read 4059 times)

Offline mschuster

  • PTeam Member
  • PixInsight Jedi
  • *****
  • Posts: 1087
MacOSX 10.7.5 graphics.end() problem?
« on: 2014 August 05 10:20:40 »
Testing new script version on MacOXS 10.7.5.

Install is PI-macosx10.6-x86_64-01.08.02.1098-20140624-c.zip with all updates.

I am seeing this error on graphics.end() on a viewport onPaint that draws a bitmap. Current script code below.

Should I not call end()? Or maybe graphics is initialized incorrectly?

Thanks,
Mike

Edit: 10.7.5 may be too old to worry about. As a workaround, I added a try/catch around the end() to catch and ignore the error. Seems to work. Is this OK?


*** Error [000]: /Volumes/BOOTCAMP/Users/Public/Documents/Astronomy/PixInsight/Scripts/SubframeSelector/SubframeSelector.0.102/SubframeSelector/SubframeSelectorBitmapBox.js, line 127: Error: Graphics.end(): the graphics context is not active

   this.viewport.onPaint = function(x0, y0, x1, y1) {
      var graphics = new Graphics(this);

      graphics.fillRect(x0, y0, x1, y1, new Brush(this.dialog.backgroundColor));
      if (this.parent.bitmap != null) {
         graphics.drawBitmap(
            this.parent.bitmapPosition.x - this.parent.scrollPosition.x,
            this.parent.bitmapPosition.y - this.parent.scrollPosition.y,
            this.parent.bitmap
         );
      }

      graphics.end();
   };

« Last Edit: 2014 August 05 11:49:08 by mschuster »

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: MacOSX 10.7.5 graphics.end() problem?
« Reply #1 on: 2014 August 05 13:04:05 »
Your code is correct. For some reason the graphics context finishes painting behind the scenes, before you call Graphics.end(). Of course this should not happen, and I doubt it has something to do with the host platform or the version of Mac OS X, since graphics generation code is 100% platform independent.

We have code like this in many scripts and it works without problems, so we have some odd interaction with the rest of your script here. Your workaround is correct and cannot break anything. When we return on September, we'll investigate this to discover the cause of this error. Sorry for the trouble.
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline mschuster

  • PTeam Member
  • PixInsight Jedi
  • *****
  • Posts: 1087
Re: MacOSX 10.7.5 graphics.end() problem?
« Reply #2 on: 2014 August 05 13:05:19 »
OK, Thank you!