mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 05:16:21 +00:00
Fix dataloss when flex inset is undefined.
Regression atcfeddb929
. 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 beforecfeddb929
. 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.
This commit is contained in:
parent
7c3fd63646
commit
f180e813fe
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user