On 03/27/2016 03:09 PM, Jean-Marc Lasgouttes wrote: > Le 27/03/2016 19:37, Jean-Marc Lasgouttes a écrit : >> I suspect a compiler bug. What is your compiler? Can you try another >> one? > > I think I know what happens: in TextClass.cpp, we have > InsetLayout DocumentClass::plain_insetlayout_; > > The InsetLayout constructor says: > InsetLayout::InsetLayout() : > [...] > font_(inherit_font), > labelfont_(sane_font), bgcolor_(Color_error), > [...] > > inherit_font and sane_font are defined in FontInfo.cpp: > > FontInfo const sane_font( > ROMAN_FAMILY, > [...] > FONT_OFF); > > FontInfo const inherit_font( > INHERIT_FAMILY, > [...] > FONT_OFF); > > Therefore, if can happen than plain_insetlayout_ is initialized before > sane_font and inherit_font have been initialized, which creates the > problems that Kornel sees. > > What is the right construct to avoid this problem?
Idea attached. Richard
diff --git a/src/TextClass.cpp b/src/TextClass.cpp index c6f3ee0..e71fed0 100644 --- a/src/TextClass.cpp +++ b/src/TextClass.cpp @@ -129,9 +129,6 @@ string translateReadType(TextClass::ReadType rt) docstring const TextClass::plain_layout_ = from_ascii(N_("Plain Layout")); -InsetLayout DocumentClass::plain_insetlayout_; - - ///////////////////////////////////////////////////////////////////////// // // TextClass @@ -1509,6 +1506,12 @@ InsetLayout const & DocumentClass::insetLayout(docstring const & name) const n = n.substr(0, i); } // Layout "name" not found. + return plainInsetLayout(); +} + + +InsetLayout const & DocumentClass::plainInsetLayout() { + static InsetLayout plain_insetlayout_; return plain_insetlayout_; } diff --git a/src/TextClass.h b/src/TextClass.h index a6ffed9..88f9303 100644 --- a/src/TextClass.h +++ b/src/TextClass.h @@ -402,7 +402,7 @@ public: /// happen). -- Idea JMarc, comment MV InsetLayout const & insetLayout(docstring const & name) const; /// a plain inset layout for use as a default - static InsetLayout const & plainInsetLayout() { return plain_insetlayout_; } + static InsetLayout const & plainInsetLayout(); /// add a new layout \c name if it does not exist in layoutlist_ /// \return whether we had to add one. bool addLayoutIfNeeded(docstring const & name) const; @@ -498,8 +498,6 @@ private: friend DocumentClassPtr getDocumentClass(LayoutFile const &, LayoutModuleList const &, bool const clone); - /// - static InsetLayout plain_insetlayout_; };