Georg Baum wrote:
> > Georg, where is this function supposed to be called?
>
> in validate() (therefore the hack with init() const and the mutable
> members). The comment says it:
>
> +       // validate() should have been called before
> +       BOOST_ASSERT(complete_);
> +

But Encoding does not have a validate member, and in Encodings::validate, the 
code below does not work.

However, the attached patch does, it fixes the asserts for me and does not 
slow down LyX. I'm committing this to get LyX back in a workable stage.

> It was something like
>
>         if (!complete_)
>                 init();
>
> This solution is sort of hackish, but I don't see a better one. The problem
> is that init() can be really expensive (if all encodings are initialized
> unconditionally startup takes over 2 minutes or so).

I noticed that (I placed it in the constructor first, which slowed LyX startup 
down to 2 minutes).

Jürgen
Index: src/Encoding.cpp
===================================================================
--- src/Encoding.cpp	(Revision 18218)
+++ src/Encoding.cpp	(Arbeitskopie)
@@ -193,8 +193,10 @@
 
 docstring const Encoding::latexChar(char_type c) const
 {
-	// validate() should have been called before
-	//BOOST_ASSERT(complete_);
+	// assure the used encoding is properly initialized
+	if (!complete_)
+		init();
+	BOOST_ASSERT(complete_);
 
 	if (c < start_encodable_)
 		return docstring(1, c);

Reply via email to