This patch updates the combo on inset unlock (bug 457558)

please apply

thanks
john

-- 
"Faced with the prospect of rereading this book, I would rather have 
 my brains ripped out by a plastic fork."
        - Charles Cooper on "Business at the Speed of Thought" 
Index: src/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/ChangeLog,v
retrieving revision 1.436
diff -u -r1.436 ChangeLog
--- src/ChangeLog       2001/12/05 15:34:41     1.436
+++ src/ChangeLog       2001/12/05 16:28:06
@@ -1,3 +1,8 @@
+2001-12-05  John Levon  <[EMAIL PROTECTED]>
+
+       * LyXView.C:
+       * BufferView2.C: fix layout combo update on inset unlock
+ 
 2001-12-05  Juergen Vigna  <[EMAIL PROTECTED]>
 
        * CutAndPaste.C (pasteSelection): remove not allowed insets/chars and
Index: src/BufferView2.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView2.C,v
retrieving revision 1.100
diff -u -r1.100 BufferView2.C
--- src/BufferView2.C   2001/11/29 12:58:57     1.100
+++ src/BufferView2.C   2001/12/05 16:28:18
@@ -456,10 +455,13 @@
        if (inset && theLockingInset() == inset) {
                inset->insetUnlock(this);
                theLockingInset(0);
+               // make sure we update the combo !
+               owner()->setLayout(getLyXText()->cursor.par()->getLayout());
                finishUndo();
                return 0;
        } else if (inset && theLockingInset() &&
                   theLockingInset()->unlockInsetInInset(this, inset)) {
+               // owner inset has updated the layout combo 
                finishUndo();
                return 0;
        }
@@ -488,7 +490,7 @@
 bool BufferView::ChangeInsets(Inset::Code code,
                              string const & from, string const & to)
 {
-       bool flag = false;
+       bool need_update = false;
        LyXCursor cursor = text->cursor;
        LyXCursor tmpcursor = cursor;
        cursor.par(tmpcursor.par());
@@ -498,20 +500,22 @@
        for (ParIterator it = buffer()->par_iterator_begin();
             it != end; ++it) {
                Paragraph * par = *it;
-               bool flag2 = false;
+               bool changed_inset = false;
                for (Paragraph::inset_iterator it2 = par->inset_iterator_begin();
                     it2 != par->inset_iterator_end(); ++it2) {
                        if ((*it2)->lyxCode() == code) {
                                InsetCommand * inset = static_cast<InsetCommand 
*>(*it2);
                                if (inset->getContents() == from) {
                                        inset->setContents(to);
-                                       flag2 = true;
+                                       changed_inset = true;
                                }
                        }
                }
-               if (flag2) {
-                       flag = true;
-#warning Fix me
+               if (changed_inset) {
+                       need_update = true;
+#ifdef WITH_WARNINGS
+#warning FIXME
+#endif
                        // The test it.size()==1 was needed to prevent crashes.
                        // How to set the cursor corretly when it.size()>1 ??
                        if (it.size() == 1) {
@@ -523,7 +527,7 @@
                }
        }
        text->setCursorIntern(this, cursor.par(), cursor.pos());
-       return flag;
+       return need_update;
 }
 
 
Index: src/LyXView.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/LyXView.C,v
retrieving revision 1.59
diff -u -r1.59 LyXView.C
--- src/LyXView.C       2001/11/29 17:12:17     1.59
+++ src/LyXView.C       2001/12/05 16:28:18
@@ -206,9 +206,9 @@
                toolbar->updateLayoutList(false);
        }
        
-       layout_type layout = bufferview->text->cursor.par()->getLayout();
+       layout_type layout = bufferview->getLyXText()->cursor.par()->getLayout();
 
-       if (layout != current_layout){
+       if (layout != current_layout) {
                toolbar->setLayout(layout);
                current_layout = layout;
        }

Reply via email to