http://bugzilla.lyx.org/show_bug.cgi?id=3401

The attached patch addresses this bug. Or part of it. It doesn't have
anything to do with pushing references: "citation-insert whomever"
causes the same crash. It seems that LFUN_CITATION_INSERT wasn't updated
to the new file format. That said, I'm not at all sure that
from_local8bit was the right thing to use here. I was just guessing. So
please tell me what I should have used.

There is, however, another issue, and it's not one I think I can solve,
namely, the crash. What was happening was that in
insets/insetcommandparams.C, a test is done for a valid command. None
was being found, and then LyX is segfaulting. I think this was happening
during the emergency save, as if the existence of the inset had already
been recorded but then it wasn't being found during the save procedure.
The line I was seeing the problem at was:
        for (size_t i = 0; i < info_->n; ++i)
in InsetCommandParams::write. I think info_n didn't exist. But I'm not sure.

Richard

-- 
==================================================================
Richard G Heck, Jr
Professor of Philosophy
Brown University
http://frege.brown.edu/heck/
==================================================================
Get my public key from http://sks.keyserver.penguin.de
Hash: 0x1DE91F1E66FFBDEC
Learn how to sign your email using Thunderbird and GnuPG at:
http://dudu.dyn.2-h.org/nist/gpg-enigmail-howto

Index: lyxfunc.C
===================================================================
--- lyxfunc.C	(revision 17717)
+++ lyxfunc.C	(working copy)
@@ -1373,16 +1373,17 @@
 				// this should be enhanced to also support text_after
 				// and citation style
 				string arg = argument;
-				string opt1;
+				string opt1 = "";
 				if (contains(argument, "|")) {
 					arg = token(argument, '|', 0);
-					opt1 = '[' + token(argument, '|', 1) + ']';
+					opt1 = token(argument, '|', 1);
 				}
-				std::ostringstream os;
-				os << "citation LatexCommand\n"
-				   << "\\cite" << opt1 << "{" << arg << "}\n"
-				   << "\\end_inset";
-				FuncRequest fr(LFUN_INSET_INSERT, os.str());
+				InsetCommandParams icp("cite");
+				icp["key"] = from_local8bit(arg);
+				if (opt1 != "")
+					icp["before"] = from_local8bit(opt1);
+				string icstr = InsetCommandMailer::params2string("citation", icp);
+				FuncRequest fr(LFUN_INSET_INSERT, icstr);
 				dispatch(fr);
 			} else
 				dispatch(FuncRequest(LFUN_DIALOG_SHOW, "citation"));

Reply via email to