Angus Leeming wrote:

> These two are both caused by LyX attempting to access GUI library
> functions without having initialised the GUI library in the first place.
> Ie, in lyx_main.C's LyX::priv_exec want_gui is false yet control is
> falling through to lyx_gui::start().
> 
> void LyX::priv_exec(int & argc, char * argv[])
> {
>     bool const want_gui = easyParse(argc, argv);
>     ...
>     lyx_gui::start(batch_command, files);
> }
> 
> I think that a band-aid (which should be applied anyway) is to protect the
> call to lyx_gui::start: "if (want_gui) lyx_gui::start(...);"

Yes. Good detective work!

> However, the real cause of the problem is presumably the failure of the
> block above to invoke exit():
> 
>     if (last_loaded) {
>         bool success = false;
>         if (last_loaded->dispatch(batch_command, &success)) {
>             QuitLyX();
>             exit(!success);
>         }
>     }

Yes, but if we always invoke exit if we are not starting a gui we are on the
safe side.

> What's also interesting is that sometimes I get the QPaintDevice error
> message and no .tex file and sometimes it just works :( valgrind doesn't
> report anything suspicious.

I always get the QPaintDevice error. I suggest to apply the attached patch.
It also removes a comment about a segfault that was most probably the same
that you observed. OK?


Georg
Index: src/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/ChangeLog,v
retrieving revision 1.2182
diff -u -p -r1.2182 ChangeLog
--- src/ChangeLog	12 May 2005 12:22:35 -0000	1.2182
+++ src/ChangeLog	18 May 2005 15:11:42 -0000
@@ -1,3 +1,52 @@
+2005-05-18  Georg Baum  <[EMAIL PROTECTED]>
+
+	* lyx_main.C (priv_exec): fix logic error with help from Angus
+	* lyx_main.C (parse_execute): set is_gui = false and remove now
+	obsolete comment about a segfault
+
 2005-05-12  Martin Vermeer  <[EMAIL PROTECTED]>
 
 	* tabular.[hC]: added setCellInset to fix tabular paste.
Index: src/lyx_main.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyx_main.C,v
retrieving revision 1.206
diff -u -p -r1.206 lyx_main.C
--- src/lyx_main.C	29 Mar 2005 14:47:54 -0000	1.206
+++ src/lyx_main.C	18 May 2005 15:11:45 -0000
@@ -278,7 +282,13 @@ void LyX::priv_exec(int & argc, char * a
 		files.clear(); // the files are already loaded
 	}
 
-	lyx_gui::start(batch_command, files);
+	if (want_gui)
+		lyx_gui::start(batch_command, files);
+	else {
+		// Something went wrong above
+		QuitLyX();
+		exit(EXIT_FAILURE);
+	}
 }
 
 
@@ -879,9 +888,7 @@ int parse_execute(string const & arg, st
 		exit(1);
 	}
 	batch = arg;
-	// Argh. Setting gui to false segfaults..
-	// FIXME: when ? how ?
-	// is_gui = false;
+	is_gui = false;
 	return 1;
 }
 

Reply via email to