From: Guillaume Munch Date: Mon, 11 Apr 2016 16:33:14 +0000 (+0100) Subject: Fix dataloss when flex inset is undefined. X-Git-Tag: 2.2.0rc1~4 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=f180e813fef22dc79c0895b65d2551b0e2603a08;p=features.git Fix dataloss when flex inset is undefined. 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. --- diff --git a/src/insets/InsetFlex.cpp b/src/insets/InsetFlex.cpp index 44b9b03436..0b14973faa 100644 --- a/src/insets/InsetFlex.cpp +++ b/src/insets/InsetFlex.cpp @@ -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); }