Author Topic: Preview agregator shows only one preview  (Read 4019 times)

Offline gvanhau

  • PixInsight Old Hand
  • ****
  • Posts: 345
Preview agregator shows only one preview
« on: 2013 February 16 11:04:31 »
Hello
On Pi 1.8 Rc3  I'm working on  workspace 2
I have an image with 4 previews.
Preview agregator script  shows only the first one

Regards
Geert
Geert Vanhauwaert

Offline Alejandro Tombolini

  • PTeam Member
  • PixInsight Jedi
  • *****
  • Posts: 1267
    • Próxima Sur
Re: Preview agregator shows only one preview
« Reply #1 on: 2013 February 16 11:14:51 »
Hi Geert, I tried in Linux and there are not problem with four preview in any workspace. I cannot check in W7
Saludos. Alejandro.

Offline gvanhau

  • PixInsight Old Hand
  • ****
  • Posts: 345
Re: Preview agregator shows only one preview
« Reply #2 on: 2013 February 16 14:45:29 »
Hello Alejandro
I think it has something to do with the workspace (I'm in workspace 2)
Even the name of the image does not correspond to the image.

Regards
Geert
Geert Vanhauwaert

Offline Gary

  • Newcomer
  • Posts: 24
Re: Preview agregator shows only one preview
« Reply #3 on: 2013 February 16 22:42:05 »
Just tried this on windows 8 and works fine across all workspaces.

Gary

Offline bitli

  • PTeam Member
  • PixInsight Guru
  • ****
  • Posts: 513
Re: Preview agregator shows only one preview
« Reply #4 on: 2013 February 17 01:14:03 »
I tried on windows 7/64, doing a clone in a workspace, then a DBE in another one (to have a 'New' image as you have), 4 previews, and it works fine. I also made a few other tests and they worked fine.

Looking at the code, it does seems unlikely that the script has a problem with workspace (it just list all views of all windows, and knows nothing of workspaces).

Maybe your workspace was corrupted ? Can you reproduce the problem ? Does it still occur if you save the project and reopen it in a new session of PI ? Do you see your image in the view list (at bottom left) ? Do you see it if you use another script that list views ? 

-- bitli

Offline bitli

  • PTeam Member
  • PixInsight Guru
  • ****
  • Posts: 513
Re: Preview agregator shows only one preview
« Reply #5 on: 2013 February 17 02:04:45 »
You may also want to try to reset the javascript runtime interpreter, if you ran other script in the same session.
I think this can be done only from the script editor, Execute/Reset Javascript Runtime.

To my surprise the execution of the scripts are not independent, and most scripts think they have the global name space for themselves. They may even add definitions to some built in objects.  In general this is not a problem (especially for relatively small scripts like PreviewAgregator), because the last one wins, but this can cause unexpected results especially if you have an errant script.

The impact can be demonstated by installing the two following scripts:

ShowGetGlobals.js:
Code: [Select]
"use strict";

// This is a test script

#feature-id Tests > ShowGetGlobal
#feature-info Show on the Console if the global variable 'pjsrTestGlobal' has some value
#define TITLE  "ShowGetGlobal"
#define VERSION "1.0"

// Get a global variable to show execution context dependencies
Console.show();

if (typeof pjsrTestGlobal == "undefined") {
  Console.writeln("Global variable pjsrTestGlobal is undefined");
} else {
  Console.writeln("Global variable pjsrTestGlobal has value '" + pjsrTestGlobal + "'");
}

and ShowSetGlobal.js
Code: [Select]
"use strict";

// This a test script

#feature-id Tests > ShowSetGlobal
#feature-info Set the global variable 'pjsrTestGlobal' to some value
#define TITLE  "ShowSetGlobal"
#define VERSION "1.0"

// Set a global variable to show execution context dependencies
Console.show();
var pjsrTestGlobal = "Some string";
Console.writeln("Global variable pjsrTestGlobal set to '" + pjsrTestGlobal + "'");

Execute ShowGetGlobal to see that the global variable is not defined, then ShowSetGlobal to set it, and ShowGetGlobal to show that it persisted across script execution. Reset the script runtime and run ShowGetGlobal to see that the global variable was indeed removed. You can make the same test directly in the editor, without installing the script, but I wanted to test if the same happened for scripts launched from the Script menu.

This may not be your problem, but reseting the Javascript runtime is worth trying in case of really bizarre behavior of a script.

-- bitli

PS to Juan:  An option to reset the script engine at each script execution to be in the safe side, especially when developing?

Offline gvanhau

  • PixInsight Old Hand
  • ****
  • Posts: 345
Re: Preview agregator shows only one preview
« Reply #6 on: 2013 February 17 12:14:38 »
Hello bitli

I just started a fresh PI session and loaded the same project, and I got the same result as before.
I then loaded three other projects and tried to do the same, and it worked Ok.

So it seems it is an isolated case.

Even saving the project  does not fix the inconvenience, however, I can live with it: I moved the image to workspace 1, then run the script and then moved the image and the agregated preview back to the workspace where I needed.

Regards
Geert

Geert Vanhauwaert