]> git.lyx.org Git - features.git/commitdiff
Fix bug 5785: http://bugzilla.lyx.org/show_bug.cgi?id=5785.
authorVincent van Ravesteijn <vfr@lyx.org>
Wed, 18 Feb 2009 23:45:00 +0000 (23:45 +0000)
committerVincent van Ravesteijn <vfr@lyx.org>
Wed, 18 Feb 2009 23:45:00 +0000 (23:45 +0000)
Reference dialog update crash for read-only documents.

Comments:
* -1 is a valid return of bufferCO->currentIndex() so we need to test for it.
* set the correct enabling of the button in case no call to updateContents follows.
* remove unneeded call to setFocusProxy. The widget is either disabled or the focus proxy is set in updateRefs.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@28547 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/GuiRef.cpp

index 40da7f7431541863436886dbf660f889d73b7ffc..b1144e372605dcab634032167334383d5765bafa 100644 (file)
@@ -55,6 +55,12 @@ GuiRef::GuiRef(GuiView & lv)
        bufferCO->setEnabled(false);
        bufferCO->hide();
 
+       // Enabling is set in updateRefs. Disable for now in case no
+       // call to updateContents follows (e.g. read-only documents).
+       sortCB->setEnabled(false);
+       refsLW->setEnabled(false);
+       gotoPB->setEnabled(false);
+
        connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
        connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply()));
        connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
@@ -82,8 +88,6 @@ GuiRef::GuiRef(GuiView & lv)
        connect(bufferCO, SIGNAL(activated(int)),
                this, SLOT(updateClicked()));
 
-       setFocusProxy(refsLW);
-
        bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
        bc().setOK(okPB);
        bc().setApply(applyPB);
@@ -361,9 +365,12 @@ void GuiRef::redoRefs()
 void GuiRef::updateRefs()
 {
        refs_.clear();
-       FileName const & name = theBufferList().fileNames()[bufferCO->currentIndex()];
-       Buffer const * buf = theBufferList().getBuffer(name);
-       buf->getLabelList(refs_);
+       int const the_buffer = bufferCO->currentIndex();
+       if (the_buffer != -1) {
+               FileName const & name = theBufferList().fileNames()[the_buffer];
+               Buffer const * buf = theBufferList().getBuffer(name);
+               buf->getLabelList(refs_);
+       }       
        sortCB->setEnabled(!refs_.empty());
        refsLW->setEnabled(!refs_.empty());
        // refsLW should only be the focus proxy when it is enabled