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
This commit is contained in:
Vincent van Ravesteijn 2009-02-18 23:45:00 +00:00
parent 106adc4b42
commit c85e24b066

View File

@ -55,6 +55,12 @@ GuiRef::GuiRef(GuiView & lv)
bufferCO->setEnabled(false); bufferCO->setEnabled(false);
bufferCO->hide(); 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(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply())); connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply()));
connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose())); connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
@ -82,8 +88,6 @@ GuiRef::GuiRef(GuiView & lv)
connect(bufferCO, SIGNAL(activated(int)), connect(bufferCO, SIGNAL(activated(int)),
this, SLOT(updateClicked())); this, SLOT(updateClicked()));
setFocusProxy(refsLW);
bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy); bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
bc().setOK(okPB); bc().setOK(okPB);
bc().setApply(applyPB); bc().setApply(applyPB);
@ -361,9 +365,12 @@ void GuiRef::redoRefs()
void GuiRef::updateRefs() void GuiRef::updateRefs()
{ {
refs_.clear(); refs_.clear();
FileName const & name = theBufferList().fileNames()[bufferCO->currentIndex()]; int const the_buffer = bufferCO->currentIndex();
Buffer const * buf = theBufferList().getBuffer(name); if (the_buffer != -1) {
buf->getLabelList(refs_); FileName const & name = theBufferList().fileNames()[the_buffer];
Buffer const * buf = theBufferList().getBuffer(name);
buf->getLabelList(refs_);
}
sortCB->setEnabled(!refs_.empty()); sortCB->setEnabled(!refs_.empty());
refsLW->setEnabled(!refs_.empty()); refsLW->setEnabled(!refs_.empty());
// refsLW should only be the focus proxy when it is enabled // refsLW should only be the focus proxy when it is enabled