]> git.lyx.org Git - lyx.git/commitdiff
Prevent crash when attempting to restore a file multiple times.
authorJuergen Spitzmueller <spitz@lyx.org>
Mon, 6 Apr 2015 07:55:07 +0000 (09:55 +0200)
committerJuergen Spitzmueller <spitz@lyx.org>
Mon, 6 Apr 2015 07:55:07 +0000 (09:55 +0200)
We currently cannot restore multiple views of the same buffer properly.
On the mac, we even crash.
So do not try it, record each file only once in the last opened list.

Fixes: #9483.
src/Session.cpp

index 6cdf1f724842558011503954a8b084eba43299f5..3fc7ca2c39bd124ee97cc614c66edb1b092a8eaf 100644 (file)
@@ -150,6 +150,16 @@ void LastOpenedSection::write(ostream & os) const
 void LastOpenedSection::add(FileName const & file, bool active)
 {
        LastOpenedFile lof(file, active);
+       // check if file is already recorded (this can happen
+       // with multiple buffer views). We do only record each
+       // file once, since we cannot restore multiple views
+       // currently, we even crash in some cases (see #9483).
+       // FIXME: Add session support for multiple views of
+       //        the same buffer (split-view etc.).
+       for (size_t i = 0; i < lastopened.size(); ++i) {
+               if (lastopened[i].file_name == file)
+                       return;
+       }
        lastopened.push_back(lof);
 }