Hi all,

a problem that comes to me from time to time is the one to open with an older version of LyX a file generated with a newer one (i.e., trying to open with 1.6 files generated with trunk).

I'm astonished by the:
1) inability of lyx to even try anything: it just refuses to load because of the unrecognized version (in the future); 2) simplicity by which I usually fix this: simply replace the \lyxformat number with the older one, and now LyX does exactly what I would expect from a "smart" tool: do the best to open the file, with possibly some data loss.

Now, it seems LyX is indeed more intelligent than it actually seems apparently to be, indeed the attached patch simply realizes the behavior 2). Of course, I'd be much more interested in seeing this backported to 1.6, anyway...

What is wrong with such an approach ?

Thanks,

    T.

Index: src/Buffer.cpp
===================================================================
--- src/Buffer.cpp	(revisione 38549)
+++ src/Buffer.cpp	(copia locale)
@@ -878,9 +878,15 @@
 	if (file_format != LYX_FORMAT) {
 		FileName tmpFile;
 		ReadStatus const ret_clf = convertLyXFormat(fn, tmpFile, file_format);
-		if (ret_clf != ReadSuccess)
+		if (ret_clf == ReadSuccess)
+			return readFile(tmpFile);
+
+		int const ret = Alert::prompt(_("Document format failure"),
+			_("Fileformat unrecognized by lyx2lyx. Trying to load anyway.\n"
+			  "Some contents might be lost, LyX might crash, or who knows what else."
+			  "Do you wish to proceed ?"), 0, 1, _("&Yes"), _("&No"));
+		if (ret == 1)
 			return ret_clf;
-		return readFile(tmpFile);
 	}
 
 	// FIXME: InsetInfo needs to know whether the file is under VCS 

Reply via email to