[Top][All Lists]

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

[Octave-bug-tracker] [bug #44219] Deleted GUI file editor tabs not forgo

From: Dan Sebald
Subject: [Octave-bug-tracker] [bug #44219] Deleted GUI file editor tabs not forgotten upon command line "exit"
Date: Sat, 14 Feb 2015 08:27:59 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:18.0) Gecko/20100101 Firefox/18.0 SeaMonkey/2.15

Follow-up Comment #9, bug #44219 (project octave):

Please try out the attached patch.  It is more along the lines of what I think
is good flow for shutdown events.  The "state variable" approach is gone,
i.e., some variable is used to indicate multiple function calls, or block
multiple function calls.  In my experience, I've never seen those convoluted
sorts of approaches work real well.  I think once the programmer tunes into
the changes in the patch, it all becomes much easier to work with.

The key changes are the following.

1) Instead of having the GUI attempt to replicated what the normal Octave
shutdown does, I've placed the following right at the front of Octave's "quit"
and "exit" routines:

@@ -806,6 +806,12 @@ to run using @code{atexit}.n
   octave_value_list retval;
+  // Confirm OK to shutdown.  Note: A dynamic function installation similar
+  // to overriding polymorphism for which the GUI can install its own "quit"
+  // yet call this base "quit" could be nice.  No link would be needed here.
+  if (! octave_link::confirm_shutdown ())
+    return retval;
   if (! quit_allowed)
     error ("quit: not supported in embedded mode");

2) Rather than place a callback function in some event queue, put "exit" in
the command queue.

@@ -985,8 +1012,7 @@ void
 main_window::closeEvent (QCloseEvent *e)
   e->ignore ();
-  if (confirm_exit_octave())
-    octave_link::post_event (this, &main_window::exit_callback);
+  queue_command ("exit");

The reason I consider this more robust is that the same exact flow of events
is being used to to exit no matter if the user types "exit" at the command
line or the GUI's close-app button or shortcut keys are used to effectively do
the same thing.  When done in this fashion, there is no tricky use of state
variables because the shutdown confirm and actual forced exit can be handle
separately via two simple signal/slot combos.

One aspect that works the shutdown confirmation work is that the worker
process (Octave core) goes into a sleep state while the GUI attempts to
shutdown.  If the user cancels, a cross-thread return variable is set before
the worker thread is awoken to continue its exit process if warranted.

The other changes have to do with the closing of the string of editor tabs. 
I've broken that up into smaller routines, of sorts, to give better
flexibility.  I think you will like the new behavior a little better.

More than that, the new setup is much easier to work with.  I'm sure there
will be some quirks here, but tweaking is very easy now.  For example, I see
that shutting down with modified files does not bring the "Editor" tab to
focus.  It brings the specific file to focus, but that file doesn't appear
unless the Editor tab is visible.  We'll probably have to also bring the
Editor tab into focus under that condition.  But these sorts of things are the
gist of the changeset.

(file #33073)

Additional Item Attachment:

File name: octave-shutdown-djs2014feb14.patch Size:26 KB


Reply to this item at:


  Message sent via/by Savannah

reply via email to

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