mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-25 10:58:52 +00:00
Fix LaTeXFeatures::useLayout() recursion test
It was broken in two ways: It was not threadsafe, and it did never detect any recursion, since the counter was decremented for each non-recursive call and never incremented again.
This commit is contained in:
parent
5a8b8ba8e1
commit
5093893b59
@ -426,10 +426,14 @@ void LaTeXFeatures::require(set<string> const & names)
|
|||||||
|
|
||||||
|
|
||||||
void LaTeXFeatures::useLayout(docstring const & layoutname)
|
void LaTeXFeatures::useLayout(docstring const & layoutname)
|
||||||
|
{
|
||||||
|
useLayout(layoutname, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void LaTeXFeatures::useLayout(docstring const & layoutname, int level)
|
||||||
{
|
{
|
||||||
// Some code to avoid loops in dependency definition
|
// Some code to avoid loops in dependency definition
|
||||||
// FIXME THREAD
|
|
||||||
static int level = 0;
|
|
||||||
const int maxlevel = 30;
|
const int maxlevel = 30;
|
||||||
if (level > maxlevel) {
|
if (level > maxlevel) {
|
||||||
lyxerr << "LaTeXFeatures::useLayout: maximum level of "
|
lyxerr << "LaTeXFeatures::useLayout: maximum level of "
|
||||||
@ -449,9 +453,7 @@ void LaTeXFeatures::useLayout(docstring const & layoutname)
|
|||||||
require(layout.requires());
|
require(layout.requires());
|
||||||
|
|
||||||
if (!layout.depends_on().empty()) {
|
if (!layout.depends_on().empty()) {
|
||||||
++level;
|
useLayout(layout.depends_on(), level + 1);
|
||||||
useLayout(layout.depends_on());
|
|
||||||
--level;
|
|
||||||
}
|
}
|
||||||
usedLayouts_.push_back(layoutname);
|
usedLayouts_.push_back(layoutname);
|
||||||
} else {
|
} else {
|
||||||
@ -459,8 +461,6 @@ void LaTeXFeatures::useLayout(docstring const & layoutname)
|
|||||||
<< to_utf8(layoutname) << "' does not exist in this class"
|
<< to_utf8(layoutname) << "' does not exist in this class"
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
--level;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -157,6 +157,8 @@ public:
|
|||||||
docstring const & htmlTitle() const { return htmltitle_; }
|
docstring const & htmlTitle() const { return htmltitle_; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
///
|
||||||
|
void useLayout(docstring const &, int);
|
||||||
///
|
///
|
||||||
std::list<docstring> usedLayouts_;
|
std::list<docstring> usedLayouts_;
|
||||||
///
|
///
|
||||||
|
Loading…
Reference in New Issue
Block a user