[patch] bug 4011: Import of CJK-LyX files leads to crash if they have extension .lyx

2007-07-12 Thread Jürgen Spitzmüller
http://bugzilla.lyx.org/show_bug.cgi?id=4011

The crash is due to an invalid pointer: when importing with indentical input 
and output file names, Converter tries to create a temporary output file in 
the temp dir, but since no buffer exists yet, buffer-tempdir() is invalid.

So the patch uses the directory dir in this case.

OK?

Jürgen
Index: src/Converter.cpp
===
--- src/Converter.cpp	(Revision 19033)
+++ src/Converter.cpp	(Arbeitskopie)
@@ -379,7 +379,11 @@
 		FileName real_outfile;
 		if (outfile == infile) {
 			real_outfile = infile;
-			outfile = FileName(addName(buffer-temppath(), tmpfile.out));
+			// when importing, a buffer does not necessarily exist
+			if (buffer)
+outfile = FileName(addName(buffer-temppath(), tmpfile.out));
+			else
+outfile = FileName(addName(path, tmpfile.out));
 		}
 
 		if (conv.latex) {


Re: [patch] bug 4011: Import of CJK-LyX files leads to crash if they have extension .lyx

2007-07-12 Thread Jean-Marc Lasgouttes
[EMAIL PROTECTED] (Jürgen Spitzmüller) writes:
 http://bugzilla.lyx.org/show_bug.cgi?id=4011

 The crash is due to an invalid pointer: when importing with indentical input 
 and output file names, Converter tries to create a temporary output file in 
 the temp dir, but since no buffer exists yet, buffer-tempdir() is invalid.

 So the patch uses the directory dir in this case.

Why not use package().temp_dir().absFilename() instead?
(Just asking)

JMarc


Re: [patch] bug 4011: Import of CJK-LyX files leads to crash if they have extension .lyx

2007-07-12 Thread Jürgen Spitzmüller
Jean-Marc Lasgouttes wrote:
  So the patch uses the directory dir in this case.

 Why not use package().temp_dir().absFilename() instead?

It didn't came to my mind.
I can do that, if you prefer.

Jürgen


Re: [patch] bug 4011: Import of CJK-LyX files leads to crash if they have extension .lyx

2007-07-12 Thread Abdelrazak Younes

Jürgen Spitzmüller wrote:

Jean-Marc Lasgouttes wrote:

So the patch uses the directory dir in this case.

Why not use package().temp_dir().absFilename() instead?


It didn't came to my mind.
I can do that, if you prefer.


Would be better IMHO.

Abdel.



Re: [patch] bug 4011: Import of CJK-LyX files leads to crash if they have extension .lyx

2007-07-12 Thread Jürgen Spitzmüller
Abdelrazak Younes wrote:
  It didn't came to my mind.
  I can do that, if you prefer.

 Would be better IMHO.

OK. Attached.

José, OK to go in?

Jürgen
Index: src/Converter.cpp
===
--- src/Converter.cpp	(Revision 19055)
+++ src/Converter.cpp	(Arbeitskopie)
@@ -29,6 +29,7 @@
 #include support/filetools.h
 #include support/lyxlib.h
 #include support/os.h
+#include support/Package.h
 #include support/Path.h
 #include support/Systemcall.h
 
@@ -50,6 +51,7 @@
 using support::makeRelPath;
 using support::onlyFilename;
 using support::onlyPath;
+using support::package;
 using support::prefixIs;
 using support::quoteName;
 using support::removeExtension;
@@ -379,7 +381,12 @@
 		FileName real_outfile;
 		if (outfile == infile) {
 			real_outfile = infile;
-			outfile = FileName(addName(buffer-temppath(), tmpfile.out));
+			// when importing, a buffer does not necessarily exist
+			if (buffer)
+outfile = FileName(addName(buffer-temppath(), tmpfile.out));
+			else
+outfile = FileName(addName(package().temp_dir().absFilename(),
+		   tmpfile.out));
 		}
 
 		if (conv.latex) {


Re: [patch] bug 4011: Import of CJK-LyX files leads to crash if they have extension .lyx

2007-07-12 Thread Jean-Marc Lasgouttes
[EMAIL PROTECTED] (Jürgen Spitzmüller) writes:

 Jean-Marc Lasgouttes wrote:
  So the patch uses the directory dir in this case.

 Why not use package().temp_dir().absFilename() instead?

 It didn't came to my mind.
 I can do that, if you prefer.

It looks better.

JMarc


Re: [patch] bug 4011: Import of CJK-LyX files leads to crash if they have extension .lyx

2007-07-12 Thread Koji Yokota

Jürgen Spitzmüller wrote:

Abdelrazak Younes wrote:
  

It didn't came to my mind.
I can do that, if you prefer.
  

Would be better IMHO.



OK. Attached.

José, OK to go in?

Jürgen
  
Is it possible to change Files of type: in UI from *.cjklyx to 
*.lyx? CJK-LyX's files have extension *.lyx, so it may be better for 
existing users.


Koji


--- lib/configure.py.orig   Thu Jul 12 22:14:54 2007
+++ lib/configure.pyThu Jul 12 22:14:54 2007
@@ -301,9 +301,9 @@
 \Format lyxlyx LyX   
 \Format lyx13x lyx13  LyX 1.3.x
document
 \Format lyx14x lyx14  LyX 1.4.x
document
-\Format clyx   cjklyx CJK LyX 1.4.x (big5) 
document
-\Format jlyx   cjklyx CJK LyX 1.4.x (euc-jp)   
document
-\Format klyx   cjklyx CJK LyX 1.4.x (euc-kr)   
document
+\Format clyx   lyx CJK LyX 1.4.x (big5)document
+\Format jlyx   lyx CJK LyX 1.4.x (euc-jp)  document
+\Format klyx   lyx CJK LyX 1.4.x (euc-kr)  document
 \Format lyxpreview lyxpreview LyX Preview  
 \Format pdftex pdftex_t PDFTEX   
 \Format program  Program   


Re: [patch] bug 4011: Import of CJK-LyX files leads to crash if they have extension .lyx

2007-07-12 Thread Jürgen Spitzmüller
Koji Yokota wrote:
 Is it possible to change Files of type: in UI from *.cjklyx to
 *.lyx? CJK-LyX's files have extension *.lyx, so it may be better for
 existing users.

The problem, I think, is that this will overwrite existing files on export. 
It's similar to bug 3934 and should be fixed in line with that:
http://bugzilla.lyx.org/show_bug.cgi?id=3934

Jürgen


Re: [patch] bug 4011: Import of CJK-LyX files leads to crash if they have extension .lyx

2007-07-12 Thread José Matos
On Thursday 12 July 2007 13:54:17 Jürgen Spitzmüller wrote:
 José, OK to go in?

 Jürgen

Yes.

-- 
José Abílio


Re: [patch] bug 4011: Import of CJK-LyX files leads to crash if they have extension .lyx

2007-07-12 Thread Jürgen Spitzmüller
José Matos wrote:
  José, OK to go in?
 
  Jürgen

 Yes.

done.

Jürgen


[patch] bug 4011: Import of CJK-LyX files leads to crash if they have extension .lyx

2007-07-12 Thread Jürgen Spitzmüller
http://bugzilla.lyx.org/show_bug.cgi?id=4011

The crash is due to an invalid pointer: when importing with indentical input 
and output file names, Converter tries to create a temporary output file in 
the temp dir, but since no buffer exists yet, buffer->tempdir() is invalid.

So the patch uses the directory dir in this case.

OK?

Jürgen
Index: src/Converter.cpp
===
--- src/Converter.cpp	(Revision 19033)
+++ src/Converter.cpp	(Arbeitskopie)
@@ -379,7 +379,11 @@
 		FileName real_outfile;
 		if (outfile == infile) {
 			real_outfile = infile;
-			outfile = FileName(addName(buffer->temppath(), "tmpfile.out"));
+			// when importing, a buffer does not necessarily exist
+			if (buffer)
+outfile = FileName(addName(buffer->temppath(), "tmpfile.out"));
+			else
+outfile = FileName(addName(path, "tmpfile.out"));
 		}
 
 		if (conv.latex) {


Re: [patch] bug 4011: Import of CJK-LyX files leads to crash if they have extension .lyx

2007-07-12 Thread Jean-Marc Lasgouttes
[EMAIL PROTECTED] (Jürgen Spitzmüller) writes:
> http://bugzilla.lyx.org/show_bug.cgi?id=4011
>
> The crash is due to an invalid pointer: when importing with indentical input 
> and output file names, Converter tries to create a temporary output file in 
> the temp dir, but since no buffer exists yet, buffer->tempdir() is invalid.
>
> So the patch uses the directory dir in this case.

Why not use package().temp_dir().absFilename() instead?
(Just asking)

JMarc


Re: [patch] bug 4011: Import of CJK-LyX files leads to crash if they have extension .lyx

2007-07-12 Thread Jürgen Spitzmüller
Jean-Marc Lasgouttes wrote:
> > So the patch uses the directory dir in this case.
>
> Why not use package().temp_dir().absFilename() instead?

It didn't came to my mind.
I can do that, if you prefer.

Jürgen


Re: [patch] bug 4011: Import of CJK-LyX files leads to crash if they have extension .lyx

2007-07-12 Thread Abdelrazak Younes

Jürgen Spitzmüller wrote:

Jean-Marc Lasgouttes wrote:

So the patch uses the directory dir in this case.

Why not use package().temp_dir().absFilename() instead?


It didn't came to my mind.
I can do that, if you prefer.


Would be better IMHO.

Abdel.



Re: [patch] bug 4011: Import of CJK-LyX files leads to crash if they have extension .lyx

2007-07-12 Thread Jürgen Spitzmüller
Abdelrazak Younes wrote:
> > It didn't came to my mind.
> > I can do that, if you prefer.
>
> Would be better IMHO.

OK. Attached.

José, OK to go in?

Jürgen
Index: src/Converter.cpp
===
--- src/Converter.cpp	(Revision 19055)
+++ src/Converter.cpp	(Arbeitskopie)
@@ -29,6 +29,7 @@
 #include "support/filetools.h"
 #include "support/lyxlib.h"
 #include "support/os.h"
+#include "support/Package.h"
 #include "support/Path.h"
 #include "support/Systemcall.h"
 
@@ -50,6 +51,7 @@
 using support::makeRelPath;
 using support::onlyFilename;
 using support::onlyPath;
+using support::package;
 using support::prefixIs;
 using support::quoteName;
 using support::removeExtension;
@@ -379,7 +381,12 @@
 		FileName real_outfile;
 		if (outfile == infile) {
 			real_outfile = infile;
-			outfile = FileName(addName(buffer->temppath(), "tmpfile.out"));
+			// when importing, a buffer does not necessarily exist
+			if (buffer)
+outfile = FileName(addName(buffer->temppath(), "tmpfile.out"));
+			else
+outfile = FileName(addName(package().temp_dir().absFilename(),
+		   "tmpfile.out"));
 		}
 
 		if (conv.latex) {


Re: [patch] bug 4011: Import of CJK-LyX files leads to crash if they have extension .lyx

2007-07-12 Thread Jean-Marc Lasgouttes
[EMAIL PROTECTED] (Jürgen Spitzmüller) writes:

> Jean-Marc Lasgouttes wrote:
>> > So the patch uses the directory dir in this case.
>>
>> Why not use package().temp_dir().absFilename() instead?
>
> It didn't came to my mind.
> I can do that, if you prefer.

It looks better.

JMarc


Re: [patch] bug 4011: Import of CJK-LyX files leads to crash if they have extension .lyx

2007-07-12 Thread Koji Yokota

Jürgen Spitzmüller wrote:

Abdelrazak Younes wrote:
  

It didn't came to my mind.
I can do that, if you prefer.
  

Would be better IMHO.



OK. Attached.

José, OK to go in?

Jürgen
  
Is it possible to change "Files of type:" in UI from "*.cjklyx" to 
"*.lyx"? CJK-LyX's files have extension "*.lyx", so it may be better for 
existing users.


Koji


--- lib/configure.py.orig   Thu Jul 12 22:14:54 2007
+++ lib/configure.pyThu Jul 12 22:14:54 2007
@@ -301,9 +301,9 @@
 \Format lyxlyx LyX"" """"  ""
 \Format lyx13x lyx13  "LyX 1.3.x" "" """"  
"document"
 \Format lyx14x lyx14  "LyX 1.4.x" "" """"  
"document"
-\Format clyx   cjklyx "CJK LyX 1.4.x (big5)"  "" """"  
"document"
-\Format jlyx   cjklyx "CJK LyX 1.4.x (euc-jp)" "" ""   ""  
"document"
-\Format klyx   cjklyx "CJK LyX 1.4.x (euc-kr)" "" ""   ""  
"document"
+\Format clyx   lyx "CJK LyX 1.4.x (big5)"  "" ""   ""  "document"
+\Format jlyx   lyx "CJK LyX 1.4.x (euc-jp)" "" ""  ""  "document"
+\Format klyx   lyx "CJK LyX 1.4.x (euc-kr)" "" ""  ""  "document"
 \Format lyxpreview lyxpreview "LyX Preview"   "" """"  ""
 \Format pdftex pdftex_t PDFTEX"" """"  ""
 \Format program""  Program"" """"  ""


Re: [patch] bug 4011: Import of CJK-LyX files leads to crash if they have extension .lyx

2007-07-12 Thread Jürgen Spitzmüller
Koji Yokota wrote:
> Is it possible to change "Files of type:" in UI from "*.cjklyx" to
> "*.lyx"? CJK-LyX's files have extension "*.lyx", so it may be better for
> existing users.

The problem, I think, is that this will overwrite existing files on export. 
It's similar to bug 3934 and should be fixed in line with that:
http://bugzilla.lyx.org/show_bug.cgi?id=3934

Jürgen


Re: [patch] bug 4011: Import of CJK-LyX files leads to crash if they have extension .lyx

2007-07-12 Thread José Matos
On Thursday 12 July 2007 13:54:17 Jürgen Spitzmüller wrote:
> José, OK to go in?
>
> Jürgen

Yes.

-- 
José Abílio


Re: [patch] bug 4011: Import of CJK-LyX files leads to crash if they have extension .lyx

2007-07-12 Thread Jürgen Spitzmüller
José Matos wrote:
> > José, OK to go in?
> >
> > Jürgen
>
> Yes.

done.

Jürgen