commit cd3d32736644477bcd6c3aac66cb197e366f168b
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 54920785b7..23c7e7e3a6 100644
--- a/src/frontends/qt/GuiView.cpp
+++ b/src/frontends/qt/GuiView.cpp
@@ -837,15 +837,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());
@@ -863,17 +860,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));
 }
 
 
@@ -2336,8 +2329,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;
        }
@@ -3668,8 +3660,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

Reply via email to