Author Topic: [1.8RC1 Win64]Access violation using TextBox in a js script  (Read 3365 times)

Offline Andres.Pozo

  • PTeam Member
  • PixInsight Padawan
  • ****
  • Posts: 927
I am debugging the ImageSolver script in 1.8 and I have found what I think is a bug in the platform:

When I change the font of a TextBox Object it launches an "Access Violation" error. I have been able to isolate it in an small test case:
Code: [Select]
#include <pjsr/FontFamily.jsh>

function TextBoxDialog()
{
   this.__base__ = Dialog;
   this.__base__();

   this.tbox = new TextBox( this );
   
   // THIS LINE PRODUCES AN ACCESS VIOLATION ERROR
   this.tbox.font = new Font(FontFamily_Helvetica, 10);
         
   this.sizer = new VerticalSizer;
   this.sizer.margin = 8;
   this.sizer.spacing = 6;
   this.sizer.add( this.tbox );

   this.windowTitle = "Test TextBox font";
   this.adjustToContents();
   this.setFixedSize();
}

TextBoxDialog.prototype = new Dialog;

var dialog = new TextBoxDialog();

dialog.execute();
If the line that changes the font is deleted the dialog works ok.

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: [1.8RC1 Win64]Access violation using TextBox in a js script
« Reply #1 on: 2013 January 02 12:28:03 »
Hi Andrés,

Bug confirmed. Surprisingly, your test script works perfectly on Linux and Mac OS X. The problem only happens on Windows.

While I fix this bug, a workaround is using a style sheet instead of setting the Control.font property:

Code: [Select]
#include <pjsr/Sizer.jsh>
#include <pjsr/FontFamily.jsh>

function TextBoxDialog()
{
   this.__base__ = Dialog;
   this.__base__();

   this.tbox = new TextBox( this );
   
   // THIS LINE PRODUCES AN ACCESS VIOLATION ERROR
   //this.tbox.font = new Font(FontFamily_Helvetica, 10);

   // This is a workaround using Control.styleSheet
   this.tbox.styleSheet = "* { font-family: Helvetica; font-size: 10pt; }";
         
   this.sizer = new VerticalSizer;
   this.sizer.margin = 8;
   this.sizer.spacing = 6;
   this.sizer.add( this.tbox );

   this.windowTitle = "Test TextBox font";
   this.adjustToContents();
   this.setFixedSize();
}

TextBoxDialog.prototype = new Dialog;

var dialog = new TextBoxDialog();

dialog.execute();

Hope this helps. Sorry for the inconvenience.
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline Andres.Pozo

  • PTeam Member
  • PixInsight Padawan
  • ****
  • Posts: 927
Re: [1.8RC1 Win64]Access violation using TextBox in a js script
« Reply #2 on: 2013 January 02 12:30:12 »
I can provide a detail that perhaps can help you: I have to change the font of the TextBox because it is different to the font used in labels and edit boxes. Is there perhaps a problem in the initialization of the TextBox?
The test have been done in Win7x64.

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: [1.8RC1 Win64]Access violation using TextBox in a js script
« Reply #3 on: 2013 January 02 12:35:48 »
By default, TextBox controls use a monospaced font (DejaVu Sans Mono on all platforms if available, or the platform's default "monospace" otherwise). No, the problem is not due to font differences. There is something wrong in PJSR's internal font management in the Windows version of 1.8.0 RC1. I have rewritten a lot of PJSR code, so there is actually no surprise here.
Juan Conejero
PixInsight Development Team
http://pixinsight.com/