help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Catching Figure close button - callbacks not running?


From: Przemek Klosowski
Subject: Re: Catching Figure close button - callbacks not running?
Date: Tue, 29 Jan 2019 14:11:47 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1

On 1/29/19 1:19 PM, Richardson, Anthony wrote:
set(gct, 'DeleteFcn' @(h, e) disp('bye bye'))

It works, but the printout seems to be buffered somehow and only appears after the next command is entered at the CLI.

Specifically, I use commandline Octave 4.2.2 on Fedora Linux, and type

    gcf=figure(1)
    set(gcf, 'DeleteFcn', @(h, e) disp('bye bye'))

nothing happens when I close the window, and I need to hit Enter on the Octave prompt to see the "bye bye" string.

I thought that it's buffered because it doesn't have a newline, but

    set(gcf, 'DeleteFcn', @(h, e) printf('bye bye\n'))

behaves in the same way. It looks like it needs an explicit fflush():

    set(gcf, 'DeleteFcn', @(h, e) {printf('bye bye\n'); fflush(stdout)})

'more off' works too.

It surprised me because we're not in octave REPL loop after the callback runs, but I guess the callbacks are buffering because the interpreter does not know in advance when they would be done running.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]