Tommaso Cucinotta schreef:
Tommaso Cucinotta ha scritto:
Abdelrazak Younes ha scritto:
Yes they help, and I hope they will help you in fixing all these cases. I only had a quick look at them but your analysis seems correct.
Ok, I'll try to produce a patch, make some tests and send it to the list.
Please, find it attached. I could not test it as I was expecting due to the lack of time.

   T.


Index: src/LyXFunc.cpp
===================================================================
--- src/LyXFunc.cpp    (revisione 31361)
+++ src/LyXFunc.cpp    (copia locale)
@@ -817,6 +817,12 @@
         Buffer * buffer = 0;
         if (lyx_view_ && lyx_view_->currentBufferView())
             buffer = &lyx_view_->currentBufferView()->buffer();
+        Buffer * doc_buffer = 0;
Shouldn't we rename buffer too then, to remove the ambiguity.
+        if (lyx_view_ && lyx_view_->documentBufferView())
+            doc_buffer = &lyx_view_->documentBufferView()->buffer();
+
+ LYXERR(Debug::ACTION, "buffer=" << buffer << ", doc_buffer=" << doc_buffer);
+

This info is not really that interesting to output.

case LFUN_BUFFER_TOGGLE_READ_ONLY: { - LASSERT(lyx_view_ && lyx_view_->currentBufferView() && buffer, /**/);
+            LASSERT(buffer, /**/);
             if (buffer->lyxvc().inUse())
                 buffer->lyxvc().toggleReadOnly();
             else

doc_buffer here!

@@ -851,19 +857,22 @@
         // --- Menus -----------------------------------------------
         case LFUN_BUFFER_CLOSE:
             lyx_view_->closeBuffer();
-            buffer = 0;
+            if (buffer == doc_buffer)
+                buffer = 0;
+            doc_buffer = 0;
             updateFlags = Update::None;
             break;
case LFUN_BUFFER_CLOSE_ALL:
             lyx_view_->closeBufferAll();
             buffer = 0;
+            doc_buffer = 0;
             updateFlags = Update::None;
             break;

if (buffer == doc_buffer)
   buffer = 0;


+        case LFUN_BUFFER_CHKTEX: // TODO: test if doc_buffer here
+            LASSERT(doc_buffer, /**/);
+            doc_buffer->runChktex();
             break;

What do you mean with the TODO.. doc_buffer is OK here if that's what you want to know.

@@ -1360,8 +1368,12 @@
                 func.origin = cmd.origin;
                 dispatch(func);
             }
-            if (theBufferList().isLoaded(buffer))
+ /// \TODO: check if some of the dispatched LFUNs in the loop above may have + /// closed (deallocated) buffer or doc_buffer before the following
Do not use /// but // and just  // FIXME. Why the  \TODO ?
"check if" -> "check whether"
Please stick to the line length limit of 80 chars (preferable somewhat less).

In the lines below it is checked whether the buffer is still loaded, so we already chack for that. What is the todo about ?


+            if (buffer && theBufferList().isLoaded(buffer))
                 buffer->undo().endUndoGroup();
if (theBufferList().isLoaded(buffer))

+ if (doc_buffer && doc_buffer != buffer && theBufferList().isLoaded(doc_buffer))
+                buffer->undo().endUndoGroup();

if (doc_buffer != buffer && theBufferList().isLoaded(doc_buffer))


             break;
         }
@@ -1416,16 +1428,16 @@
             lyx_view_->message(from_utf8(argument));
             break;
- case LFUN_BUFFER_LANGUAGE: {
-            LASSERT(lyx_view_, /**/);
-            Language const * oldL = buffer->params().language;
+ case LFUN_BUFFER_LANGUAGE: { // Check if this is for buffer or doc_buffer

"Check if" -> "Check whether"
This is doc_buffer, as an internal buffer doesn't have params.. well it has params, but you can't set them. I'd guess that you use the doc_buffer's params when you need params in your internal buffer.



+ /// \TODO Check/ask if this is for buffer or doc_buffer
         case LFUN_BUFFER_PARAMS_APPLY: {
Same as above.


         }
+ /// \TODO check/ask if these MODULES_* LFUNs may work on internal WorkAreas as well
         case LFUN_LAYOUT_MODULES_CLEAR: {

Same as above.


@@ -1661,20 +1677,32 @@
                     if (theBufferList().isLoaded(buffer))
                         buffer->undo().endUndoGroup();
                 }
+ if (lyx_view_->documentBufferView() && lyx_view_->documentBufferView() != lyx_view_->currentBufferView()) { + updateFlags = lyx_view_->documentBufferView()->cursor().result().update();

Stick to a max of 80 chars.



+ // First try to dispatch to currentBufferView its own actions. + if (buffer && lyx_view_->currentBufferView()->dispatch(cmd)) {
                 // The BufferView took care of its own updates if needed.
                 updateFlags = Update::None;
                 if (theBufferList().isLoaded(buffer))
                     buffer->undo().endUndoGroup();
                 break;
+ } else if (doc_buffer && lyx_view_->documentBufferView()->dispatch(cmd)) { + /// \TODO Check if correct: we dispatch to documentBufferView() as well, in this case ?
+                // The BufferView took care of its own updates if needed.
+                updateFlags = Update::None;
+                if (theBufferList().isLoaded(doc_buffer))
+                    doc_buffer->undo().endUndoGroup();
+                break;
             }

This is not really correct, because we don't know whether we have to dispatch to buffer or doc_buffer.

We should somehow make sure that BufferView->dispatch returns false if it is an internal buffer and we dispatched an LFUN meant for doc_buffer. Now, nothing will be succesfully dispatched to doc_buffer.


+            LASSERT(buffer, /**/);
+

Why this ?



@@ -1732,10 +1762,11 @@
         }
// if we executed a mutating lfun, mark the buffer as dirty
-        if (theBufferList().isLoaded(buffer) && flag.enabled()
+        if (doc_buffer && !doc_buffer->isInternal()

How can the doc_buffer be internal ? doc_buffer may be 0 because the next condition will then be false.

+            && theBufferList().isLoaded(doc_buffer) && flag.enabled()
             && !lyxaction.funcHasFlag(action, LyXAction::NoBuffer)
             && !lyxaction.funcHasFlag(action, LyXAction::ReadOnly))
- buffer->markDirty(); + doc_buffer->markDirty();

Vincent

Reply via email to