Author Topic: [PJSR] Many crashes in GUI functions  (Read 3019 times)

Offline bitli

  • PTeam Member
  • PixInsight Guru
  • ****
  • Posts: 513
[PJSR] Many crashes in GUI functions
« on: 2012 December 17 13:00:22 »
Hello,
Beyond the crash in case you forget a closing brace, PI also crashes in case some parameter of a GUI function is missing or undefined.
For example an undefined parent, or a parent not initialized in a GroupBox before doing some operations, or many similar situations, crashes PI (Windows 7 / 64 bits).

I am reorganizing a UI interface and I spend evenings restarting PI and guessing which variable may have caused the crash. Very similar to assembly code programming on the first IBM PC. Except that I am much worst at Javascript than at assembly :-)

It would be nice if all functions called by the script verified the parameters, at least to the point of not crashing the program. May be in PI 1.8 ?

-- bitli

Offline bitli

  • PTeam Member
  • PixInsight Guru
  • ****
  • Posts: 513
Re: [PJSR] Many crashes in GUI functions
« Reply #1 on: 2013 March 10 10:38:15 »
In the following code I forgot to add a control to a Sizer.
This blocks PI which must be killed (from console or task manager). This is true for all recent PI on Windows and Unix.

Clearly this is a bug in the script, as it does not make sense to create a control without adding it somewhere. However if there was a way to avoid PI crashing, this would be nice.

-- bitli

Code: [Select]
// DO NOT RUN THIS, IT WILL CRASH PI
function TestMDialog()
{
   this.__base__ = Dialog;
   this.__base__();

   this.title = "Test";

   this.sizer = new HorizontalSizer;
   this.okPushButton = new PushButton( this );
   this.okPushButton.text = "OK" ;
   this.okPushButton.onPress = function() {this.dialog.ok()};

   this.cancelPushButton = new PushButton( this );
   this.cancelPushButton.text = "Cancel";
   this.cancelPushButton.onPress = function() {this.dialog.cancel()};
}

TestMDialog.prototype = new Dialog;


function main()
{

   console.show();

   //{
      var dialog =  new TestMDialog();

      if (!dialog.execute())
      {
         // User cancelled
         return;
      }

}

main();