commit 8884c4044d7c1d29526aca7b0be1734231c89207
Author: Jean-Marc Lasgouttes <[email protected]>
Date:   Mon Jul 18 16:44:06 2016 +0200

    Add feedback in status bar when zooming
    
    Moreover enforce better the lower limit of 10 and avoid overflow due
    to unsigned int.
    
    Fixes bug #10212.
---
 src/LyXRC.cpp                 |    2 ++
 src/frontends/qt4/GuiView.cpp |   20 ++++++++++++++------
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/src/LyXRC.cpp b/src/LyXRC.cpp
index 8b7c3b3..7696d09 100644
--- a/src/LyXRC.cpp
+++ b/src/LyXRC.cpp
@@ -604,6 +604,8 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool 
check_format)
 
                case RC_SCREEN_ZOOM:
                        lexrc >> zoom;
+                       if (zoom < 10)
+                               zoom = 10;
                        break;
 
                case RC_GEOMETRY_SESSION:
diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp
index b94625b..1342eb7 100644
--- a/src/frontends/qt4/GuiView.cpp
+++ b/src/frontends/qt4/GuiView.cpp
@@ -1990,6 +1990,8 @@ bool GuiView::getStatus(FuncRequest const & cmd, 
FuncStatus & flag)
 
        case LFUN_BUFFER_ZOOM_OUT:
                enable = doc_buffer && lyxrc.zoom > 10;
+               if (lyxrc.zoom <= 10)
+                       flag.message(_("Zoom level cannot be less than 10%."));
                break;
 
        case LFUN_BUFFER_ZOOM_IN:
@@ -3933,17 +3935,22 @@ void GuiView::dispatch(FuncRequest const & cmd, 
DispatchResult & dr)
                        break;
 
                case LFUN_BUFFER_ZOOM_IN:
-               case LFUN_BUFFER_ZOOM_OUT:
+               case LFUN_BUFFER_ZOOM_OUT: {
+                       // use a signed temp to avoid overflow
+                       int zoom = lyxrc.zoom;
                        if (cmd.argument().empty()) {
                                if (cmd.action() == LFUN_BUFFER_ZOOM_IN)
-                                       lyxrc.zoom += 20;
+                                       zoom += 20;
                                else
-                                       lyxrc.zoom -= 20;
+                                       zoom -= 20;
                        } else
-                               lyxrc.zoom += convert<int>(cmd.argument());
+                               zoom += convert<int>(cmd.argument());
 
-                       if (lyxrc.zoom < 10)
-                               lyxrc.zoom = 10;
+                       if (zoom < 10)
+                               zoom = 10;
+                       lyxrc.zoom = zoom;
+
+                       dr.setMessage(bformat(_("Zoom level is now %1$d%"), 
lyxrc.zoom));
 
                        // The global QPixmapCache is used in GuiPainter to 
cache text
                        // painting so we must reset it.
@@ -3951,6 +3958,7 @@ void GuiView::dispatch(FuncRequest const & cmd, 
DispatchResult & dr)
                        guiApp->fontLoader().update();
                        lyx::dispatch(FuncRequest(LFUN_SCREEN_FONT_UPDATE));
                        break;
+               }
 
                case LFUN_VC_REGISTER:
                case LFUN_VC_RENAME:

Reply via email to