09/04/2013 23:11, Pavel Sanda:
I also tried this but then the Length() conversion fails because this is
not a valid length.

Did you read JMarc reply?

To be more precise, an empty length has unit UNIT_NONE. You can set a length to empty state with the default constructor:
  mylength = Length();

Contrary to what I thought, I found no place of the code where it is possible to skip a length value in a LengthCombo. However, it would be easy to test for the QtextEdit vlaue and set length to empty when needed. This is not something we want to do in general, though.

In any case, there is no particular problem in terms of representation in the LyX file, the notion of empty lenght is supported.

I suspect however that the following patch is needed. Pavel, what do you think?

JMarc


diff --git a/src/lengthcommon.cpp b/src/lengthcommon.cpp
index 217c22b..72f5bbf 100644
--- a/src/lengthcommon.cpp
+++ b/src/lengthcommon.cpp
@@ -236,8 +236,11 @@ bool isValidGlueLength(string const & data, GlueLength * result)
 	// forward approach leads to very long, tedious code that would be
 	// much harder to understand and maintain. (AS)
 
-	if (data.empty())
+	if (data.empty()) {
+		if (result)
+			*result = GlueLength();
 		return true;
+	}
 	string buffer = ltrim(data);
 
 	// To make isValidGlueLength recognize negative values as
@@ -306,8 +309,11 @@ bool isValidLength(string const & data, Length * result)
 	// The parser may seem overkill for lengths without
 	// glue, but since we already have it, using it is
 	// easier than writing something from scratch.
-	if (data.empty())
+	if (data.empty()) {
+		if (result)
+			*result = Length();
 		return true;
+	}
 
 	string   buffer = data;
 	int      pattern_index = 0;

Reply via email to