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

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

[Octave-bug-tracker] [bug #45273] GUI editor does not attempt to save th


From: Dan Sebald
Subject: [Octave-bug-tracker] [bug #45273] GUI editor does not attempt to save the modified contents of unnamed files at close
Date: Mon, 08 Jun 2015 06:24:55 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:18.0) Gecko/20100101 Firefox/18.0 SeaMonkey/2.15

URL:
  <http://savannah.gnu.org/bugs/?45273>

                 Summary: GUI editor does not attempt to save the modified
contents of unnamed files at close
                 Project: GNU Octave
            Submitted by: sebald
            Submitted on: Mon 08 Jun 2015 06:24:54 AM GMT
                Category: GUI
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Incorrect Result
                  Status: None
             Assigned to: None
         Originator Name: 
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: dev
        Operating System: Any

    _______________________________________________________

Details:

I'm in the process of reworking the quit/exit code for another bug report, and
I noticed that changes in a new tab, i.e., one for which the tab is labelled
"* <unnamed>", are not inquired to save when the GUI editor closes at exit. 
I've fixed this in the code I'm working on.  I can leave the fix for this as
part of the changeset I'm about to wrap up, or create a separate one.  Any
preference?

I will summarize the problem and solution:

The way the editor works at save/confirm is to create a list/table of the
files and tab IDs by querying all the tabs, then step through the list
processing the tabs for which the contents has been changed.  However, the
file_editor_tab does not report unnamed files:


void
file_editor_tab::file_name_query (const QWidget *ID)
{
  // A zero (null pointer) means that all file editor tabs
  // should respond, otherwise just the desired file editor tab.
  if (ID != this && ID != 0)
    return;

  // Unnamed files shouldn't be transmitted.
  if (!_file_name.isEmpty ())
    emit add_filename_to_list (_file_name, this);
}


Well, the logical approach is to simply to remove that conditional test at the
end of the function and always add the file name.  That works, except for
another required change.  Adding the file name is as follows:


void
file_editor::handle_add_filename_to_list (const QString& fileName,
file_editor_tab *ID)
{
  // Should we allow multiple tabs for a single file?
  editor_tab_map[fileName] = ID;
}


Since the file name for all unnamed files is empty, that means if there are
multiple "* <unnamed>" files then the fileName is not unique and all but one
of the unnamed files is lost.

On the other hand, ID is unique.  So the solution is to swap the roles of
fileName and ID.  That is, make ID the independent variable:


  std::map<file_editor_tab *, QString> editor_tab_map;

  typedef std::map<file_editor_tab *, QString>::iterator
editor_tab_map_iterator;
  typedef std::map<file_editor_tab *, QString>::const_iterator
editor_tab_map_const_iterator;


and then of course swap p->first and p->second in the use of the iterator.




    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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