octave-bug-tracker
[Top][All Lists]
Advanced

[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: Wed, 11 Feb 2015 19:19:16 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:18.0) Gecko/20100101 Firefox/18.0 SeaMonkey/2.15

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

I must have not formatted something correctly and the bulk of my comment was
deleted.  OK, retype...

I've looked at this patch and would like to revisit this. The close mechanism
looks a little more clumsy than it needs to be, highlighted by this line of
code:


  // Here, we really want to exit and all tabs are closed
  _check_closing_done = true;  // check is already done, prevent a second
check
                               // which would store an empty file list


Whenever I see that kind of a construct in an object-oriented framework I
think there should be a better solution, given past experience.  A
ground-upward solution that reuses smaller routines inside more comprehensive
functions.  I think rather than trying to do the save/close simultaneously,
it's better to go through the list twice, first save then close.

I assume that when the user closes a tab when not exiting (i.e., just normal
operation), there is a check for save, then close.  Let's call that
CheckSave().  (I'll use contrived names for illustration.)  Something like:


void CheckClose ()
{
  if (CheckSave() != CANCEL)
    Close();
}


Now, upon "exit", if we go through the list and first just save, the user
canceling will not have closed any tabs, so the user can type exit again and
again without having any tabs closed, so no need for  _check_closing_done. 
That is:


  // Save all tabs, checking for user cancel.
  file_editor_tab *editor_tab;
  for (int index = _tab_widget->count ()-1; index >= 0; index--)
    {
      editor_tab = static_cast <file_editor_tab *> (_tab_widget->widget
(index));
      if ((! editor_tab->CheckSave (closing_state)) && closing_state == 1)
        return false;
    }

  // Close all tabs.  All files were just saved so checking is redundant.
  for (int index = _tab_widget->count ()-1; index >= 0; index--)
    {
      editor_tab = static_cast <file_editor_tab *> (_tab_widget->widget
(index));
      editor_tab->CheckClose ();
    }


Also, let's try to get that static_cast out of the code.  In this case it
isn't too dangerous, but in my mind, using a cast means we are deviating from
the paradigm of the widget framework.

Should I attempt a changeset?  Or do you understand what I'm saying and can
fix things in a straightforward way?

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?44219>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

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