On 08/16/2009 06:36 PM, Tommaso Cucinotta wrote:
LyX Ticket Tracker ha scritto:
Comment(by lasgouttes):

I think the fix is wrong. The undo group should be created just before a
 (series of) recordUndo calls and the group should be closed in the end.
From the frontend, the changes to the document should as much as possible be done through LFUNS. Could you show me in the code the places where the
 document is modified (and recordUndo called)?
Hello,

the way the findWorkArea and replaceWorkArea are modified is exactly the same as the document work area is modified, i.e., by means of LFUNs. Typing characters triggers some LFUN_SELF_INSERT, which causes the characters to be entered into the work area which has the current focus.

AFAICS, the problem is that, in LyXFunc.cpp and Text*.cpp, there is plenty of places where the buffer that is being acted upon is implicitly considered the document buffer, and it is not retrieved by other means of the currentWorkArea() method (in fact, this is unfortunately a method of GuiWorkArea as of now), but for example as: lyx_view_->buffer() or others. Therefore, what happens is that the beginUndoGroup() call which is called when you start typing into the findWorkArea (LyXFunc.cpp:1672 ?) is called on the bad Cursor/Buffer/Undo instance, i.e., on the Undo of the main document buffer, rather than on the one of the find buffer. And I guess this is why when the recordUndo() is done, instead, on the find buffer, the error is displayed.

Appearenlty, there is no visible malfunctioning (undo seems to work correctly both on document, and on work areas, also by alternating undo/redo actions on all of them), however this incorrect pattern of usage of undo groups might lead to problems on the long run.

The real fix that I can think of requires the following changes:
1) moving awareness of the difference between the currentWorkArea() [ the one with focus, i.e., document, find, or replace WAs ] and the currentMainWorkArea() [ the one with the main document being edited ] from GuiView.cpp (as it is now) to LyXView.cpp (or other non-qt-specific classes);
2) within Text*.cpp, add the proper buffer retrieval code

The second change seems to me the most troublesome, due to the plethora of ways in which the buffer is retrieved, comprising retrieving the bufferview, the lyxview, the cursor, etc...

Comments ?

One: Abdel is probably the one who needs to answer this question. Unfortunately, he's on vacation with everyone else in France.

rh

Reply via email to