Le 18/07/2012 06:39, Scott Kostyshak a écrit :
From: Jean-Marc Lasgouttes [lasgout...@lyx.org]
Sent: Sunday, July 15, 2012 5:14 PM
>Moreover, this code should not be in GuiView, but in
>GuiApplication, since the function is at application level.
Attached is my attempt to move the code to GuiApplication. I am having trouble
instantiating a GuiWorkArea. Here are the errors I get:
GuiApplication.cpp: In member function ‘virtual void
lyx::frontend::GuiApplication::dispatch(const lyx::FuncRequest&,
lyx::DispatchResult&)’:
GuiApplication.cpp:1633:8: error: invalid use of incomplete type ‘class
lyx::frontend::GuiWorkArea’
In file included from GuiApplication.cpp:15:0:
GuiApplication.h:41:7: error: forward declaration of ‘class
lyx::frontend::GuiWorkArea’
Try to #include "GuiWorkArea.h" at the start of GuiApplication.cpp.
I think that this patch also addresses the other points you raised.
It begins to look very good. See below for comments.
JMarc
+ case LFUN_BUFFER_FORALL: {
+ GuiView * cv = currentView();
What if currentView() is null? I propose to do an early return in this
case. Or maybe this can happen when all buffers are hidden and requires
finer codeing. I do not know whether this is only a theoretical
possibility, this may happen when using client to do scripting. On the
mac at least, LyX can be running witout having any open window.
Unless you want to be very complete, it is probably enough right now to
return early.
I do not think I have seen "cv" used as the name of a GuiView. From a
quick poll if the source, I suggest "gv" or "view". The good thing about
using a known name is that it requires less effort for the reader of the
code.
+ Buffer * const buf = &cv->currentBufferView()->buffer();
Do we have a bufferview when the LyX window is there but no buffer is open?
+ FuncRequest FuncToRun = lyxaction.lookupFunc(commandToRun);
FuncRequest const funcToRun =...
(constify and no capitalization of variable names)
+ dr.setMessage(bformat(_("%1$s%2$s"), msg,
from_utf8(commandToRun)));
+ Buffer * const last = theBufferList().last();
+ Buffer * b = theBufferList().first();
+ Buffer * nextBuf = 0;
+ // We cannot use a for loop as the buffer list cycles.
+ while (true) {
+ if (b != last)
+ nextBuf = theBufferList().next(b); //get next
now bc LFUN might close current
+
+ bool const hidden = !(guiApp->currentView() &&
guiApp->currentView()->workArea(*b));
No need to use guiApp-> there. Are you using currentView() because cv
could become invalid? If so, why do you use it below?
BTW, what happens if several windows are open? It looks like you are not
going to see whether the buffers on other windows are
+ if (hidden) {
+ if (processHidden) {
+ cv->setBuffer(b);
+ lyx::dispatch(FuncToRun);
+ GuiWorkArea * const wa =
cv->currentWorkArea();
+ wa->view().hideWorkArea(wa);
I am not sure that the intermediate wa variable is useful here.
+ }
+ }
+
+ else {
+ if (processVisible) {
else if (processvisible) { ...