commit 1a09839df96733b7e955c9f8119bfd0540a7c426
Author: Jean-Marc Lasgouttes <[email protected]>
Date: Sun May 11 20:23:00 2025 +0200
Do not use a version of dispatch() that use a DispatchResult if not using it
There are basically two types of dispatch functions. Those which have
no DispatchResult parameter clean up after themselves and do whatever
updates have been requested.
On the other hand, those with a DispatchResult prameter expect to be
part of a larger dispatch() chain and modify the DR that is passed to
them so that it is taken into account.
tl;dr: never declare a DR variable if you do not intend to do
something with it after calling dispatch.
---
src/frontends/qt/GuiView.cpp | 21 ++++++---------------
1 file changed, 6 insertions(+), 15 deletions(-)
diff --git a/src/frontends/qt/GuiView.cpp b/src/frontends/qt/GuiView.cpp
index 470be5ef67..db9bc3f47a 100644
--- a/src/frontends/qt/GuiView.cpp
+++ b/src/frontends/qt/GuiView.cpp
@@ -833,15 +833,12 @@ void GuiView::checkCancelBackground()
void GuiView::statsPressed()
{
- DispatchResult dr;
- dispatch(FuncRequest(LFUN_STATISTICS), dr);
+ lyx::dispatch(FuncRequest(LFUN_STATISTICS));
}
void GuiView::zoomSliderMoved(int value)
{
- DispatchResult dr;
- dispatch(FuncRequest(LFUN_BUFFER_ZOOM, convert<string>(value)), dr);
- scheduleRedrawWorkAreas();
+ lyx::dispatch(FuncRequest(LFUN_BUFFER_ZOOM, convert<string>(value)));
zoom_value_->setText(toqstr(bformat(_("[[ZOOM]]%1$d%"), value)));
zoom_in_->setEnabled(currentBufferView()
&& value < zoom_slider_->maximum());
@@ -859,17 +856,13 @@ void GuiView::zoomValueChanged(int value)
void GuiView::zoomInPressed()
{
- DispatchResult dr;
- dispatch(FuncRequest(LFUN_BUFFER_ZOOM_IN), dr);
- scheduleRedrawWorkAreas();
+ lyx::dispatch(FuncRequest(LFUN_BUFFER_ZOOM_IN));
}
void GuiView::zoomOutPressed()
{
- DispatchResult dr;
- dispatch(FuncRequest(LFUN_BUFFER_ZOOM_OUT), dr);
- scheduleRedrawWorkAreas();
+ lyx::dispatch(FuncRequest(LFUN_BUFFER_ZOOM_OUT));
}
@@ -2228,8 +2221,7 @@ int GuiView::nextError(string const & error_type, bool
from_master,
continue;
}
if (navigateto) {
- DispatchResult dr;
- dispatch(TexRow::goToFunc(err.start, err.end), dr);
+ lyx::dispatch(TexRow::goToFunc(err.start, err.end));
}
return item;
}
@@ -3551,8 +3543,7 @@ bool GuiView::exportBufferAs(Buffer & b, docstring const
& iformat)
}
FuncRequest cmd(LFUN_BUFFER_EXPORT, fmt_name + " " +
fname.absFileName());
- DispatchResult dr;
- dispatch(cmd, dr);
+ DispatchResult dr = lyx::dispatch(cmd);
return dr.dispatched();
}
--
lyx-cvs mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-cvs