Jean-Marc Lasgouttes wrote:
rgheck <[EMAIL PROTECTED]> writes:

OK, progress. The attached patch seems to fix the bug.

The patch looks good. Note however that getLayout is defined at Inset
level, so you do not need to play tricks with InsetCollapsable.
There is a getLayout(BufferParams const &), but the one I was using is getLayout(), which is only defined in InsetCollapsable. I could use the other one, but there's a lot of weirdness here, now that I look at it. I take it that Inset::getLayout(BufferParams const &) is supposed to return the layout for that inset. But what it actually does is call DocumentClass::insetLayout(docstring), which returns the layout with a certain name. So, e.g., a call to InsetCollapsable::getLayout(BufferParams const &) would return the InsetLayout named "Collapsable"---or would, if it weren't overridden. So this is just wrong, and we don't run into a problem because it's only used with Collapsables.

I propose we get rid of Inset::getLayout() altogether. It's not needed. As the attached shows.

I tried the same thing with FontInfo::realize, which is supposed to be
the right interface here, but it did not work. update() is more a
helper for the GUI. Do you have an idea of why it does not work?

Well, that turns out to be what we need. My patch crashed because it wasn't returning a fully realized font. I'd tried that before, too, and abandoned it. But it turns out that it wasn't working because I had the arguments in the wrong order: The already realized "template" has to be the argument, with realize() itself called on the font that may have *_INHERIT.

Finally, the lines
                if (layout.font.family() == INHERIT_FAMILY)
                        
lf.setFamily(buffer.params().getFont().fontInfo().family());
(which are Juergen's) do not look right. I would have expected
something like
                lf.realize(buffer.params().getFont().fontInfo());

I do not know why the family is singled out like that.

Should we wait and ask him?

rh

Index: insets/InsetFoot.cpp
===================================================================
--- insets/InsetFoot.cpp	(revision 26161)
+++ insets/InsetFoot.cpp	(working copy)
@@ -55,7 +55,7 @@
 		cnts.step(foot);
 		// FIXME: the counter should format itself.
 		custom_label_= support::bformat(from_utf8("%1$s %2$s"),
-					  translateIfPossible(getLayout(buffer().params()).labelstring()),
+					  translateIfPossible(getLayout().labelstring()),
 					  cnts.theCounter(foot));
 		setLabel(custom_label_);
 	
Index: insets/Inset.cpp
===================================================================
--- insets/Inset.cpp	(revision 26161)
+++ insets/Inset.cpp	(working copy)
@@ -416,12 +416,6 @@
 }
 
 
-InsetLayout const & Inset::getLayout(BufferParams const & bp) const
-{
-	return bp.documentClass().insetLayout(name());  
-}
-
-
 void Inset::dump() const
 {
 	write(lyxerr);
Index: insets/Inset.h
===================================================================
--- insets/Inset.h	(revision 26161)
+++ insets/Inset.h	(working copy)
@@ -380,8 +380,6 @@
 	// used there don't correspond to what is used here. 
 	///
 	virtual docstring name() const;
-	///
-	virtual InsetLayout const & getLayout(BufferParams const & bp) const;
 	/// used to toggle insets
 	/// is the inset open?
 	/// should this inset be handled like a normal charater
Index: insets/InsetCollapsable.h
===================================================================
--- insets/InsetCollapsable.h	(revision 26161)
+++ insets/InsetCollapsable.h	(working copy)
@@ -45,8 +45,6 @@
 	///
 	docstring name() const { return from_ascii("Collapsable"); }
 	///
-	InsetLayout const & getLayout(BufferParams const &) const { return *layout_; }
-	///
 	InsetLayout const & getLayout() const { return *layout_; } 
 	///
 	void setLayout(BufferParams const &);
Index: Text3.cpp
===================================================================
--- Text3.cpp	(revision 26161)
+++ Text3.cpp	(working copy)
@@ -2098,8 +2100,13 @@
 
 	case LFUN_INSET_DISSOLVE:
 		if (!cmd.argument().empty()) {
-			InsetLayout il = cur.inset().getLayout(cur.buffer().params());
-			enable = cur.inset().lyxCode() == FLEX_CODE
+			InsetCollapsable * icp = cur.inset().asInsetCollapsable();
+			if (!icp) {
+				enable = false;
+				break;
+			}
+			InsetLayout const & il = icp->getLayout();
+			enable = icp->lyxCode() == FLEX_CODE
 			         && il.lyxtype() == to_utf8(cmd.argument());
 		} else {
 			enable = !isMainText(cur.bv().buffer()) 

Reply via email to