bug with log window

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

bug with log window

Gannier, François
Dear all (and mostly Wayne and Michael),

Since version 1.52 (until the 1.52q48) , I found a annoying bug when I first open the log window.
To show this, I create a simply 'action tool'.

macro "Test Bug Action Tool - C000T1g06BT8g06uTeg06g" {
    run("Confocal Series (2.2MB)");
    videoID = getImageID();
    run("Plot Z-axis Profile");
    plotID = getImageID();
    IJ.log("loaded...");
    selectImage(plotID);
    if (isActive(plotID)) print("true"); else print("false");
    eval("script","WindowManager.getActiveWindow()");
    Vaxis = eval("script","WindowManager.getActiveWindow().getPlot().getLabel('y')");
    print(Vaxis);
}

with version prior to 1.52, you get :
    loaded...
    true
    confocal-series.tif-0-0
    Mean

from version 1.52, you get the first time:
    loaded...
    true
    ij.text.TextWindow[frame0,0,701,410x298,layout=java.awt.BorderLayout,title=Log,resizable,normal]
    TypeError: WindowManager.getActiveWindow().getPlot is not a function in <eval> at line number 1

and the next time (with the log window still opened)
    loaded...
    true
    confocal-series-1.tif-0-0
    Mean

Since version 1.52, the Log window stole the focus when it first opens and doesn't give back to the previous even after the selectImage function.
What is surprising is that the function isActive says that the plot windows is active in each case.

Best regards,
François

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: bug with log window

Michael Schmid
Dear Francois,

(and to the group after some private discussion):

Writing to the Log window for the first time brings it to the foreground
(as far as I can say, this has been the case since the early days of
ImageJ).
Essentially it is undetermined when exactly the Log window appears on
the screen; if it happens to appear after the selectImage, then the
front window becomes the Log. These timing issues may depend on the
operating system.

Thus, if one wants to refer to an *image* window, it is always better to
use a method that returns the active *image*, irrespective of non-image
windows, such as the Log. Such java/JavaScript functions are
   IJ.getImage() or
   WindowManager.getActiveImage()

I think that it was not a problem for your macro before version 1.52o30,
where the following code was introduced in the TextWindow class:
                else if (id==WindowEvent.WINDOW_ACTIVATED)
                        WindowManager.setWindow(this);

I guess that this was a bug fix:
Without that code functions that *should* return the front window
(including non-image windows) would sometimes not know that the Log (or
other TextWindows) are in the foreground. Such functions are, e.g., the
macro functions
    getInfo("window.type")
    getInfo("window.title")
    getInfo("window.contents") [for text windows such as the Log]


Michael
________________________________________________________________
On 17.09.19 17:06, François Gannier (Dpt) wrote:

> Dear Michael, Wayne
>
> With the next code,
>
> macro "Test Bug Action Tool - C000T1g06BT8g06uTeg06g" {
>      run("About ImageJ...");
>      run("Duplicate...", " ");
>      dupID = getImageID();
>      IJ.log("loaded...");
>      selectImage(dupID);
>      if (isActive(dupID)) print("true"); else print("false");
>      eval("script","WindowManager.getActiveWindow()");
>      getInfo("window.title");
> }
>
> that's what I get, the first time:
> loaded...
>      true
> ij.text.TextWindow[frame0,26,498,400x388,layout=java.awt.BorderLayout,title=Log,resizable,normal]
>      Log
>
> and the next time:
>      loaded...
>      true
>      About ImageJ-2
>      About ImageJ-2
>
> However, I'm working under a linux distribution with OpenJava 11,
> So I test this on a windows 7 machine with Java 6 and all is working
> correctly, ie the log window stays in background (like version prior to
> 1.52)
> I tried to change java version from 11 to 8 on linux, but the error
> persists (when it is created the log window stole the focus).
>
> I tried to activate the "debug mode" as suggested, but this opens the
> Log window, so the error didn't happened....
>
> Best regards,
> François.
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: bug with log window

Wayne Rasband-2
In reply to this post by Gannier, François
> On Sep 17, 2019, at 3:38 AM, Gannier, François <[hidden email]> wrote:
>
> Dear all (and mostly Wayne and Michael),
>
> Since version 1.52 (until the 1.52q48) , I found a annoying bug when I first open the log window.
> To show this, I create a simply 'action tool’.

Thanks to Michael Schmid, this 1.52o regression is fixed in the latest ImageJ daily build (1.52r2).

-wayne

> macro "Test Bug Action Tool - C000T1g06BT8g06uTeg06g" {
>    run("Confocal Series (2.2MB)");
>    videoID = getImageID();
>    run("Plot Z-axis Profile");
>    plotID = getImageID();
>    IJ.log("loaded...");
>    selectImage(plotID);
>    if (isActive(plotID)) print("true"); else print("false");
>    eval("script","WindowManager.getActiveWindow()");
>    Vaxis = eval("script","WindowManager.getActiveWindow().getPlot().getLabel('y')");
>    print(Vaxis);
> }
>
> with version prior to 1.52, you get :
>    loaded...
>    true
>    confocal-series.tif-0-0
>    Mean
>
> from version 1.52, you get the first time:
>    loaded...
>    true
>    ij.text.TextWindow[frame0,0,701,410x298,layout=java.awt.BorderLayout,title=Log,resizable,normal]
>    TypeError: WindowManager.getActiveWindow().getPlot is not a function in <eval> at line number 1
>
> and the next time (with the log window still opened)
>    loaded...
>    true
>    confocal-series-1.tif-0-0
>    Mean
>
> Since version 1.52, the Log window stole the focus when it first opens and doesn't give back to the previous even after the selectImage function.
> What is surprising is that the function isActive says that the plot windows is active in each case.
>
> Best regards,
> François

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html