[PATCH] Fix crash exporting a multi-part document at the command-line

2007-07-10 Thread Abdelrazak Younes
This patch revert part of the code changed in revision 18825. This is 
needed because there is no lyx_view_ when exporting at the command-line.


OK?

Abdel.

Index: InsetInclude.cpp
===
--- InsetInclude.cpp(revision 19003)
+++ InsetInclude.cpp(working copy)
@@ -404,9 +404,19 @@
// the readonly flag can/will be wrong, not anymore I think.
if (!fs::exists(included_file.toFilesystemEncoding()))
return false;
-   lyx::dispatch(FuncRequest(LFUN_BUFFER_CHILD_OPEN,
-   included_file.absFilename() + |true));
-   buf = theBufferList().getBuffer(included_file.absFilename());
+   if (use_gui) {
+   lyx::dispatch(FuncRequest(LFUN_BUFFER_CHILD_OPEN,
+   included_file.absFilename() + |true));
+   buf = 
theBufferList().getBuffer(included_file.absFilename());
+   }
+   else {
+   buf = 
theBufferList().newBuffer(included_file.absFilename());
+   if (!loadLyXFile(buf, included_file)) {
+   //close the buffer we just opened
+   theBufferList().close(buf, false);
+   return false;
+   }
+   }
return buf;
}
buf-setParentName(parentFilename(buffer));


Re: [PATCH] Fix crash exporting a multi-part document at the command-line

2007-07-10 Thread Jean-Marc Lasgouttes
 Abdelrazak == Abdelrazak Younes [EMAIL PROTECTED] writes:

Abdelrazak This patch revert part of the code changed in revision
Abdelrazak 18825. This is needed because there is no lyx_view_ when
Abdelrazak exporting at the command-line.

Why is the lyx_view_ needed?

Also, I know it does not come from your patch, I really do not like
this weird |true syntax below:
+   lyx::dispatch(FuncRequest(LFUN_BUFFER_CHILD_OPEN,
+   included_file.absFilename() + |true));

This is definitely not how we define arguments. We should really
refrain from making our ``API'' even worse than it currently is.

JMarc


Re: [PATCH] Fix crash exporting a multi-part document at the command-line

2007-07-10 Thread Abdelrazak Younes

Jean-Marc Lasgouttes wrote:

Abdelrazak == Abdelrazak Younes [EMAIL PROTECTED] writes:


Abdelrazak This patch revert part of the code changed in revision
Abdelrazak 18825. This is needed because there is no lyx_view_ when
Abdelrazak exporting at the command-line.

Why is the lyx_view_ needed?


LFUN_BUFFER_CHILD_OPEN uses LyXView::loadLyXFile() because of outline, 
tabbar, etc.




Also, I know it does not come from your patch, I really do not like
this weird |true syntax below:
+   lyx::dispatch(FuncRequest(LFUN_BUFFER_CHILD_OPEN,
+   included_file.absFilename() + |true));


Note that Richard asked for comment at the time. But I agree with you 
it's not very nice.




This is definitely not how we define arguments. We should really
refrain from making our ``API'' even worse than it currently is.


I agree and I already started to take care of this in mvc branch which 
will be merged either in 1.5.1 or in 1.6svn.


But for the time being, let's please get 1.5.0 out.

Abdel.



Re: [PATCH] Fix crash exporting a multi-part document at the command-line

2007-07-10 Thread Jean-Marc Lasgouttes
 Abdelrazak == Abdelrazak Younes [EMAIL PROTECTED] writes:

 Why is the lyx_view_ needed?

Abdelrazak LFUN_BUFFER_CHILD_OPEN uses LyXView::loadLyXFile() because
Abdelrazak of outline, tabbar, etc.

OK.

Abdelrazak Note that Richard asked for comment at the time. 

Sure, but he did not point to this particular feature :)

Abdelrazak I agree and I already started to take care of this in mvc
Abdelrazak branch which will be merged either in 1.5.1 or in 1.6svn.

I am not sure Juergen will be willing to merge something big in 1.5.1
(or later). But cleanup is much welcome.

Abdelrazak But for the time being, let's please get 1.5.0 out.

Sure. In this respect, your patch is OK.


Re: [PATCH] Fix crash exporting a multi-part document at the command-line

2007-07-10 Thread José Matos
On Tuesday 10 July 2007 15:56:04 Jean-Marc Lasgouttes wrote:
 Abdelrazak But for the time being, let's please get 1.5.0 out.

 Sure. In this respect, your patch is OK.

+1

-- 
José Abílio


Re: [PATCH] Fix crash exporting a multi-part document at the command-line

2007-07-10 Thread Abdelrazak Younes

José Matos wrote:

On Tuesday 10 July 2007 15:56:04 Jean-Marc Lasgouttes wrote:

Abdelrazak But for the time being, let's please get 1.5.0 out.

Sure. In this respect, your patch is OK.


+1


Done, thanks.



Re: [PATCH] Fix crash exporting a multi-part document at the command-line

2007-07-10 Thread Abdelrazak Younes

Jean-Marc Lasgouttes wrote:
Abdelrazak Note that Richard asked for comment at the time. 


Sure, but he did not point to this particular feature :)


IIRC he asked what was the correct syntax for argument but nobody 
(including me) answered him.



Abdelrazak I agree and I already started to take care of this in mvc
Abdelrazak branch which will be merged either in 1.5.1 or in 1.6svn.

I am not sure Juergen will be willing to merge something big in 1.5.1
(or later).


I plan the open the debate as soon as 1.5.0 is out ;-)

Abdel.



Re: [PATCH] Fix crash exporting a multi-part document at the command-line

2007-07-10 Thread Richard Heck

Jean-Marc Lasgouttes wrote:

Abdelrazak == Abdelrazak Younes [EMAIL PROTECTED] writes:

Abdelrazak Note that Richard asked for comment at the time. 


Sure, but he did not point to this particular feature :)
  
I'm pretty sure he did: 
http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg120884.html. 
Indeed, how to define the optional argument was one of the major issues. 
(The other option was a new LFUN.) And while I'm prepared to believe 
that this is not how we define arguments, | is used as a delimiter 
for an optional argument in the code just preceding this:


case LFUN_CITATION_INSERT: {
BOOST_ASSERT(lyx_view_);
if (!argument.empty()) {
// we can have one optional argument, delimited by '|'
// citation-insert key|text_before
// this should be enhanced to also support text_after
// and citation style
string arg = argument;
string opt1;
if (contains(argument, |)) {
arg = token(argument, '|', 0);
opt1 = token(argument, '|', 1);
}
InsetCommandParams icp(cite);
icp[key] = from_utf8(arg);
if (!opt1.empty())
icp[before] = from_utf8(opt1);
string icstr = InsetCommandMailer::params2string(citation, 
icp);
FuncRequest fr(LFUN_INSET_INSERT, icstr);
dispatch(fr);
} else
dispatch(FuncRequest(LFUN_DIALOG_SHOW_NEW_INSET, citation));
break;
}

That's where I got the idea.

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



Re: [PATCH] Fix crash exporting a multi-part document at the command-line

2007-07-10 Thread Jean-Marc Lasgouttes
 Richard == Richard Heck [EMAIL PROTECTED] writes:

Richard I'm pretty sure he did:
Richard http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg120884.html.

[PATCH] Child TOC Crash, Again
Richard Heck
Sat, 16 Jun 2007 10:14:39 -0700

Hey, that's not fair! I was busy preparing a garden party for 80 people!

To be fair, some of the messages in the thread are familiar to me...

Richard Indeed, how to define the optional argument was one of the
Richard major issues. (The other option was a new LFUN.) And while
Richard I'm prepared to believe that this is not how we define
Richard arguments, | is used as a delimiter for an optional
Richard argument in the code just preceding this:

Richard, it looks like my tone felt a bit rude to you. Sorry about
that.

Actually I would prefer a syntax like

buffer-child-insert file-name-in-optional quotes 
or
buffer-child-insert file-name-in-optional quotes true

Anyway, as Abdel rightfully pointed out this is work for later.

JMarc



Re: [PATCH] Fix crash exporting a multi-part document at the command-line

2007-07-10 Thread Richard Heck

Jean-Marc Lasgouttes wrote:

Hey, that's not fair! I was busy preparing a garden party for 80 people!

To be fair, some of the messages in the thread are familiar to me...

Richard Indeed, how to define the optional argument was one of the
Richard major issues. (The other option was a new LFUN.) And while
Richard I'm prepared to believe that this is not how we define
Richard arguments, | is used as a delimiter for an optional
Richard argument in the code just preceding this:

Richard, it looks like my tone felt a bit rude to you. Sorry about
that.
  

No, I didn't take offense.

Actually I would prefer a syntax like

buffer-child-insert file-name-in-optional quotes 
or

buffer-child-insert file-name-in-optional quotes true

Anyway, as Abdel rightfully pointed out this is work for later.
  
And there's a similar question about the citation-insert code that 
precedes. It'd be quite easy at this point to do the enhancement 
mentioned there, but there's a question about the format of the command.


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



Re: [PATCH] Fix crash exporting a multi-part document at the command-line

2007-07-10 Thread Jean-Marc Lasgouttes
 Richard == Richard Heck [EMAIL PROTECTED] writes:

Richard And there's a similar question about the citation-insert code
Richard that precedes. It'd be quite easy at this point to do the
Richard enhancement mentioned there, but there's a question about the
Richard format of the command.

We should try to come up with some kind of syntax for these lfuns. I
am confident this will eventually happen :)

JMarc


[PATCH] Fix crash exporting a multi-part document at the command-line

2007-07-10 Thread Abdelrazak Younes
This patch revert part of the code changed in revision 18825. This is 
needed because there is no lyx_view_ when exporting at the command-line.


OK?

Abdel.

Index: InsetInclude.cpp
===
--- InsetInclude.cpp(revision 19003)
+++ InsetInclude.cpp(working copy)
@@ -404,9 +404,19 @@
// the readonly flag can/will be wrong, not anymore I think.
if (!fs::exists(included_file.toFilesystemEncoding()))
return false;
-   lyx::dispatch(FuncRequest(LFUN_BUFFER_CHILD_OPEN,
-   included_file.absFilename() + "|true"));
-   buf = theBufferList().getBuffer(included_file.absFilename());
+   if (use_gui) {
+   lyx::dispatch(FuncRequest(LFUN_BUFFER_CHILD_OPEN,
+   included_file.absFilename() + "|true"));
+   buf = 
theBufferList().getBuffer(included_file.absFilename());
+   }
+   else {
+   buf = 
theBufferList().newBuffer(included_file.absFilename());
+   if (!loadLyXFile(buf, included_file)) {
+   //close the buffer we just opened
+   theBufferList().close(buf, false);
+   return false;
+   }
+   }
return buf;
}
buf->setParentName(parentFilename(buffer));


Re: [PATCH] Fix crash exporting a multi-part document at the command-line

2007-07-10 Thread Jean-Marc Lasgouttes
> "Abdelrazak" == Abdelrazak Younes <[EMAIL PROTECTED]> writes:

Abdelrazak> This patch revert part of the code changed in revision
Abdelrazak> 18825. This is needed because there is no lyx_view_ when
Abdelrazak> exporting at the command-line.

Why is the lyx_view_ needed?

Also, I know it does not come from your patch, I really do not like
this weird "|true" syntax below:
+   lyx::dispatch(FuncRequest(LFUN_BUFFER_CHILD_OPEN,
+   included_file.absFilename() + "|true"));

This is definitely not how we define arguments. We should really
refrain from making our ``API'' even worse than it currently is.

JMarc


Re: [PATCH] Fix crash exporting a multi-part document at the command-line

2007-07-10 Thread Abdelrazak Younes

Jean-Marc Lasgouttes wrote:

"Abdelrazak" == Abdelrazak Younes <[EMAIL PROTECTED]> writes:


Abdelrazak> This patch revert part of the code changed in revision
Abdelrazak> 18825. This is needed because there is no lyx_view_ when
Abdelrazak> exporting at the command-line.

Why is the lyx_view_ needed?


LFUN_BUFFER_CHILD_OPEN uses LyXView::loadLyXFile() because of outline, 
tabbar, etc.




Also, I know it does not come from your patch, I really do not like
this weird "|true" syntax below:
+   lyx::dispatch(FuncRequest(LFUN_BUFFER_CHILD_OPEN,
+   included_file.absFilename() + "|true"));


Note that Richard asked for comment at the time. But I agree with you 
it's not very nice.




This is definitely not how we define arguments. We should really
refrain from making our ``API'' even worse than it currently is.


I agree and I already started to take care of this in mvc branch which 
will be merged either in 1.5.1 or in 1.6svn.


But for the time being, let's please get 1.5.0 out.

Abdel.



Re: [PATCH] Fix crash exporting a multi-part document at the command-line

2007-07-10 Thread Jean-Marc Lasgouttes
> "Abdelrazak" == Abdelrazak Younes <[EMAIL PROTECTED]> writes:

>> Why is the lyx_view_ needed?

Abdelrazak> LFUN_BUFFER_CHILD_OPEN uses LyXView::loadLyXFile() because
Abdelrazak> of outline, tabbar, etc.

OK.

Abdelrazak> Note that Richard asked for comment at the time. 

Sure, but he did not point to this particular "feature" :)

Abdelrazak> I agree and I already started to take care of this in mvc
Abdelrazak> branch which will be merged either in 1.5.1 or in 1.6svn.

I am not sure Juergen will be willing to merge something big in 1.5.1
(or later). But cleanup is much welcome.

Abdelrazak> But for the time being, let's please get 1.5.0 out.

Sure. In this respect, your patch is OK.


Re: [PATCH] Fix crash exporting a multi-part document at the command-line

2007-07-10 Thread José Matos
On Tuesday 10 July 2007 15:56:04 Jean-Marc Lasgouttes wrote:
> Abdelrazak> But for the time being, let's please get 1.5.0 out.
>
> Sure. In this respect, your patch is OK.

+1

-- 
José Abílio


Re: [PATCH] Fix crash exporting a multi-part document at the command-line

2007-07-10 Thread Abdelrazak Younes

José Matos wrote:

On Tuesday 10 July 2007 15:56:04 Jean-Marc Lasgouttes wrote:

Abdelrazak> But for the time being, let's please get 1.5.0 out.

Sure. In this respect, your patch is OK.


+1


Done, thanks.



Re: [PATCH] Fix crash exporting a multi-part document at the command-line

2007-07-10 Thread Abdelrazak Younes

Jean-Marc Lasgouttes wrote:
Abdelrazak> Note that Richard asked for comment at the time. 


Sure, but he did not point to this particular "feature" :)


IIRC he asked what was the correct syntax for argument but nobody 
(including me) answered him.



Abdelrazak> I agree and I already started to take care of this in mvc
Abdelrazak> branch which will be merged either in 1.5.1 or in 1.6svn.

I am not sure Juergen will be willing to merge something big in 1.5.1
(or later).


I plan the open the debate as soon as 1.5.0 is out ;-)

Abdel.



Re: [PATCH] Fix crash exporting a multi-part document at the command-line

2007-07-10 Thread Richard Heck

Jean-Marc Lasgouttes wrote:

"Abdelrazak" == Abdelrazak Younes <[EMAIL PROTECTED]> writes:

Abdelrazak> Note that Richard asked for comment at the time. 


Sure, but he did not point to this particular "feature" :)
  
I'm pretty sure he did: 
http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg120884.html. 
Indeed, how to define the optional argument was one of the major issues. 
(The other option was a new LFUN.) And while I'm prepared to believe 
that this is "not how we define arguments", "|" is used as a delimiter 
for an optional argument in the code just preceding this:


case LFUN_CITATION_INSERT: {
BOOST_ASSERT(lyx_view_);
if (!argument.empty()) {
// we can have one optional argument, delimited by '|'
// citation-insert |
// this should be enhanced to also support text_after
// and citation style
string arg = argument;
string opt1;
if (contains(argument, "|")) {
arg = token(argument, '|', 0);
opt1 = token(argument, '|', 1);
}
InsetCommandParams icp("cite");
icp["key"] = from_utf8(arg);
if (!opt1.empty())
icp["before"] = from_utf8(opt1);
string icstr = InsetCommandMailer::params2string("citation", 
icp);
FuncRequest fr(LFUN_INSET_INSERT, icstr);
dispatch(fr);
} else
dispatch(FuncRequest(LFUN_DIALOG_SHOW_NEW_INSET, "citation"));
break;
}

That's where I got the idea.

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



Re: [PATCH] Fix crash exporting a multi-part document at the command-line

2007-07-10 Thread Jean-Marc Lasgouttes
> "Richard" == Richard Heck <[EMAIL PROTECTED]> writes:

Richard> I'm pretty sure he did:
Richard> http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg120884.html.

>[PATCH] Child TOC Crash, Again
>Richard Heck
>Sat, 16 Jun 2007 10:14:39 -0700

Hey, that's not fair! I was busy preparing a garden party for 80 people!

To be fair, some of the messages in the thread are familiar to me...

Richard> Indeed, how to define the optional argument was one of the
Richard> major issues. (The other option was a new LFUN.) And while
Richard> I'm prepared to believe that this is "not how we define
Richard> arguments", "|" is used as a delimiter for an optional
Richard> argument in the code just preceding this:

Richard, it looks like my tone felt a bit rude to you. Sorry about
that.

Actually I would prefer a syntax like

buffer-child-insert "file-name-in-optional quotes" 
or
buffer-child-insert "file-name-in-optional quotes" true

Anyway, as Abdel rightfully pointed out this is work for later.

JMarc



Re: [PATCH] Fix crash exporting a multi-part document at the command-line

2007-07-10 Thread Richard Heck

Jean-Marc Lasgouttes wrote:

Hey, that's not fair! I was busy preparing a garden party for 80 people!

To be fair, some of the messages in the thread are familiar to me...

Richard> Indeed, how to define the optional argument was one of the
Richard> major issues. (The other option was a new LFUN.) And while
Richard> I'm prepared to believe that this is "not how we define
Richard> arguments", "|" is used as a delimiter for an optional
Richard> argument in the code just preceding this:

Richard, it looks like my tone felt a bit rude to you. Sorry about
that.
  

No, I didn't take offense.

Actually I would prefer a syntax like

buffer-child-insert "file-name-in-optional quotes" 
or

buffer-child-insert "file-name-in-optional quotes" true

Anyway, as Abdel rightfully pointed out this is work for later.
  
And there's a similar question about the citation-insert code that 
precedes. It'd be quite easy at this point to do the enhancement 
mentioned there, but there's a question about the format of the command.


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



Re: [PATCH] Fix crash exporting a multi-part document at the command-line

2007-07-10 Thread Jean-Marc Lasgouttes
> "Richard" == Richard Heck <[EMAIL PROTECTED]> writes:

Richard> And there's a similar question about the citation-insert code
Richard> that precedes. It'd be quite easy at this point to do the
Richard> enhancement mentioned there, but there's a question about the
Richard> format of the command.

We should try to come up with some kind of syntax for these lfuns. I
am confident this will eventually happen :)

JMarc