mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 10:00:33 +00:00
Fixup c30b0aac
: protect against bad recursion
Adding this particular line created bad redraw interactions. See thread on lyx-devel here: https://marc.info/?l=lyx-devel&m=165648365808777&w=2 The code is reorganized a bit: - the part of updateGUI() that (en|dis)abled elements is not moved to updateBottons ; the rest is renamed updateWorkAreas() - only updateButtons is called now in eventFilter - finally the recursion curse is fixed now in updateWorkAreas() by setting the old_buffer value _before_ calling copy_params. This avoid recursion if some bad update were to happen again.
This commit is contained in:
parent
8c8f558c4d
commit
2104ae8068
@ -86,7 +86,7 @@ void FindAndReplaceWidget::dockLocationChanged(Qt::DockWidgetArea area)
|
||||
|
||||
bool FindAndReplaceWidget::eventFilter(QObject * obj, QEvent * event)
|
||||
{
|
||||
updateGUI();
|
||||
updateButtons();
|
||||
if (event->type() != QEvent::KeyPress
|
||||
|| (obj != find_work_area_ && obj != replace_work_area_))
|
||||
return QWidget::eventFilter(obj, event);
|
||||
@ -644,13 +644,6 @@ bool FindAndReplaceWidget::initialiseParams(std::string const & /*params*/)
|
||||
}
|
||||
|
||||
|
||||
void FindAndReplace::updateView()
|
||||
{
|
||||
widget_->updateGUI();
|
||||
widget_->updateButtons();
|
||||
}
|
||||
|
||||
|
||||
FindAndReplace::FindAndReplace(GuiView & parent,
|
||||
Qt::DockWidgetArea area,
|
||||
Qt::WindowFlags flags)
|
||||
@ -683,25 +676,17 @@ bool FindAndReplace::initialiseParams(std::string const & params)
|
||||
}
|
||||
|
||||
|
||||
void FindAndReplaceWidget::updateGUI()
|
||||
void FindAndReplaceWidget::updateWorkAreas()
|
||||
{
|
||||
BufferView * bv = view_.documentBufferView();
|
||||
if (bv) {
|
||||
if (old_buffer_ != &bv->buffer()) {
|
||||
old_buffer_ = &bv->buffer();
|
||||
copy_params(*bv, find_work_area_->bufferView());
|
||||
copy_params(*bv, replace_work_area_->bufferView());
|
||||
old_buffer_ = &bv->buffer();
|
||||
}
|
||||
} else
|
||||
old_buffer_ = nullptr;
|
||||
|
||||
bool const find_enabled = !find_work_area_->bufferView().buffer().empty();
|
||||
findNextPB->setEnabled(find_enabled);
|
||||
bool const replace_enabled = find_enabled && bv && !bv->buffer().isReadonly();
|
||||
replaceLabel->setEnabled(replace_enabled);
|
||||
replace_work_area_->setEnabled(replace_enabled);
|
||||
replacePB->setEnabled(replace_enabled);
|
||||
replaceallPB->setEnabled(replace_enabled);
|
||||
}
|
||||
|
||||
|
||||
@ -718,6 +703,22 @@ void FindAndReplaceWidget::updateButtons()
|
||||
replacePB->setText(qt_("Rep&lace >"));
|
||||
replacePB->setToolTip(qt_("Replace and find next occurrence (Enter, backwards: Shift+Enter)"));
|
||||
}
|
||||
|
||||
BufferView * bv = view_.documentBufferView();
|
||||
bool const find_enabled = !find_work_area_->bufferView().buffer().empty();
|
||||
findNextPB->setEnabled(find_enabled);
|
||||
bool const replace_enabled = find_enabled && bv && !bv->buffer().isReadonly();
|
||||
replaceLabel->setEnabled(replace_enabled);
|
||||
replace_work_area_->setEnabled(replace_enabled);
|
||||
replacePB->setEnabled(replace_enabled);
|
||||
replaceallPB->setEnabled(replace_enabled);
|
||||
}
|
||||
|
||||
|
||||
void FindAndReplace::updateView()
|
||||
{
|
||||
widget_->updateWorkAreas();
|
||||
widget_->updateButtons();
|
||||
}
|
||||
|
||||
|
||||
|
@ -33,7 +33,7 @@ class FindAndReplaceWidget : public QTabWidget, public Ui::FindAndReplaceUi
|
||||
public:
|
||||
FindAndReplaceWidget(GuiView & view);
|
||||
bool initialiseParams(std::string const & params);
|
||||
void updateGUI();
|
||||
void updateWorkAreas();
|
||||
void updateButtons();
|
||||
|
||||
// return true if \c wa is one if the adv. F&R workareas
|
||||
|
Loading…
Reference in New Issue
Block a user