]> git.lyx.org Git - lyx.git/commitdiff
Fix dataloss when flex inset is undefined.
authorGuillaume Munch <gm@lyx.org>
Mon, 11 Apr 2016 16:33:14 +0000 (17:33 +0100)
committerGuillaume Munch <gm@lyx.org>
Mon, 11 Apr 2016 20:02:06 +0000 (21:02 +0100)
Regression at cfeddb929. If a flex inset has no layout upon saving (e.g. if a
module has been deleted) then its name became lost. This checks whether the name
resolution, introduced with the ObsoletedBy tag, comes back empty-handed (which
it will if the layout is not defined). In this case, we do as was done before
cfeddb929.

In addition, the use of support::token to strip "Flex:" off the beginning of the
name introduces a regression if somebody used a name containing ":". This
replaces it with support::split.

src/insets/InsetFlex.cpp

index 44b9b034360b0174bd5a306785c9e117dd4fb466..0b14973faa46fe06c323f4738371e5a62aa4a44d 100644 (file)
@@ -68,19 +68,24 @@ InsetLayout::InsetDecoration InsetFlex::decoration() const
 void InsetFlex::write(ostream & os) const
 {
        os << "Flex ";
-       InsetLayout const & il = getLayout();
+       string name;
        if (name_.empty())
-               os << "undefined";
+               name = "undefined";
        else {
-               // use il.name(), since this resolves obsoleted
-               // InsetLayout names
-               string name = to_utf8(il.name());
-               // Remove the "Flex:" prefix, if it is present
-               if (support::prefixIs(name, "Flex:"))
-                       name = support::token(name, ':', 1);
-               os << name;
+               InsetLayout const & il = getLayout();
+               // use il.name(), since this resolves obsoleted InsetLayout names
+               if (il.name() == "undefined")
+                       // This is the name of the plain_insetlayout_. We assume that the
+                       // name resolution has failed.
+                       name = name_;
+               else {
+                       name = to_utf8(il.name());
+                       // Remove the "Flex:" prefix, if it is present
+                       if (support::prefixIs(name, "Flex:"))
+                               name = support::split(name, ':');
+               }
        }
-       os << "\n";
+       os << name << "\n";
        InsetCollapsable::write(os);
 }