From ee8a336cbc407e7fb587e2c155fee8c7a5d76e1e Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Tue, 26 Feb 2019 16:37:41 +0100 Subject: [PATCH] Update screen as needed when preferences are changed This commit removes the adhoc code in GuiPrefs and moves it to LyXRC, so that it triggers in every preference change. The code has also been updated to trigger on more variables, e.g. font_*_foundry. Note that the actual function that are called have not been changed (addPreviews and LFUN_SCREEN_FONT_UPDATE), although there are doubts that they behave as needed (see FIXMEs). Fixes bug #11498. (cherry picked from commit 954531f247adee029c12713634a81717f87a2bcf) --- src/LyXRC.cpp | 25 +++++++++++- src/frontends/qt4/GuiApplication.cpp | 3 ++ src/frontends/qt4/GuiPrefs.cpp | 58 +++------------------------- src/frontends/qt4/GuiPrefs.h | 9 ----- status.23x | 6 ++- 5 files changed, 36 insertions(+), 65 deletions(-) diff --git a/src/LyXRC.cpp b/src/LyXRC.cpp index 71f184d69d..67530bd3e3 100644 --- a/src/LyXRC.cpp +++ b/src/LyXRC.cpp @@ -23,6 +23,8 @@ #include "Converter.h" #include "FontEnums.h" #include "Format.h" +#include "FuncCode.h" +#include "FuncRequest.h" #include "Lexer.h" #include "LyX.h" #include "Mover.h" @@ -3003,6 +3005,14 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new) } // fall through case LyXRC::RC_PREVIEW: + if (lyxrc_orig.preview != lyxrc_new.preview) { + // Update all previews of all documents. + /* FIXME: this can be very expensive. It would be cheaper + * to kill all existing previews and update visible + * previews.*/ + theBufferList().updatePreviews(); + } + // fall through case LyXRC::RC_PREVIEW_HASHED_LABELS: case LyXRC::RC_PREVIEW_SCALE_FACTOR: case LyXRC::RC_PRINTLANDSCAPEFLAG: @@ -3011,6 +3021,7 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new) case LyXRC::RC_SAVE_COMPRESSED: case LyXRC::RC_SAVE_ORIGIN: case LyXRC::RC_SCREEN_DPI: + case LyXRC::RC_SCREEN_FONT_ROMAN: case LyXRC::RC_SCREEN_FONT_ROMAN_FOUNDRY: case LyXRC::RC_SCREEN_FONT_SANS: @@ -3019,8 +3030,20 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new) case LyXRC::RC_SCREEN_FONT_SIZES: case LyXRC::RC_SCREEN_FONT_TYPEWRITER: case LyXRC::RC_SCREEN_FONT_TYPEWRITER_FOUNDRY: - case LyXRC::RC_GEOMETRY_SESSION: case LyXRC::RC_SCREEN_ZOOM: + if (lyxrc_orig.roman_font_name != lyxrc_new.roman_font_name + || lyxrc_orig.sans_font_name != lyxrc_new.sans_font_name + || lyxrc_orig.typewriter_font_name != lyxrc_new.typewriter_font_name + || lyxrc_orig.roman_font_foundry != lyxrc_new.roman_font_foundry + || lyxrc_orig.sans_font_foundry != lyxrc_new.sans_font_foundry + || lyxrc_orig.use_scalable_fonts != lyxrc_new.use_scalable_fonts + || lyxrc_orig.font_sizes != lyxrc_new.font_sizes + || lyxrc_orig.typewriter_font_foundry != lyxrc_new.typewriter_font_foundry + || lyxrc_orig.defaultZoom != lyxrc_new.defaultZoom) { + dispatch(FuncRequest(LFUN_SCREEN_FONT_UPDATE)); + } + + case LyXRC::RC_GEOMETRY_SESSION: case LyXRC::RC_SERVERPIPE: case LyXRC::RC_SET_COLOR: case LyXRC::RC_SHOW_BANNER: diff --git a/src/frontends/qt4/GuiApplication.cpp b/src/frontends/qt4/GuiApplication.cpp index 3c6e137e46..3d88764c73 100644 --- a/src/frontends/qt4/GuiApplication.cpp +++ b/src/frontends/qt4/GuiApplication.cpp @@ -1632,6 +1632,9 @@ void GuiApplication::dispatch(FuncRequest const & cmd, DispatchResult & dr) case LFUN_SCREEN_FONT_UPDATE: { // handle the screen font changes. + /* FIXME: this only updates the current document, whereas all + * documents should see their metrics updated. + */ d->font_loader_.update(); dr.screenUpdate(Update::Force | Update::FitCursor); break; diff --git a/src/frontends/qt4/GuiPrefs.cpp b/src/frontends/qt4/GuiPrefs.cpp index 58810dfb85..ae0986ecc0 100644 --- a/src/frontends/qt4/GuiPrefs.cpp +++ b/src/frontends/qt4/GuiPrefs.cpp @@ -1101,19 +1101,6 @@ void PrefScreenFonts::applyRC(LyXRC & rc) const rc.font_sizes[FONT_SIZE_HUGE] = widgetToDoubleStr(screenHugeED); rc.font_sizes[FONT_SIZE_HUGER] = widgetToDoubleStr(screenHugerED); rc.use_pixmap_cache = pixmapCacheCB->isChecked(); - - if (rc.font_sizes != oldrc.font_sizes - || rc.roman_font_name != oldrc.roman_font_name - || rc.sans_font_name != oldrc.sans_font_name - || rc.typewriter_font_name != oldrc.typewriter_font_name - || rc.defaultZoom != oldrc.defaultZoom) { - // The global QPixmapCache is used in GuiPainter to cache text - // painting so we must reset it in case any of the above - // parameter is changed. - QPixmapCache::clear(); - guiApp->fontLoader().update(); - form_->updateScreenFonts(); - } } @@ -1447,16 +1434,10 @@ void PrefDisplay::applyRC(LyXRC & rc) const rc.preview = LyXRC::PREVIEW_OFF; break; case 1: - if (rc.preview != LyXRC::PREVIEW_NO_MATH) { - rc.preview = LyXRC::PREVIEW_NO_MATH; - form_->updatePreviews(); - } + rc.preview = LyXRC::PREVIEW_NO_MATH; break; case 2: - if (rc.preview != LyXRC::PREVIEW_ON) { - rc.preview = LyXRC::PREVIEW_ON; - form_->updatePreviews(); - } + rc.preview = LyXRC::PREVIEW_ON; break; } @@ -3537,8 +3518,7 @@ void PrefIdentity::updateRC(LyXRC const & rc) ///////////////////////////////////////////////////////////////////// GuiPreferences::GuiPreferences(GuiView & lv) - : GuiDialog(lv, "prefs", qt_("Preferences")), update_screen_font_(false), - update_previews_(false) + : GuiDialog(lv, "prefs", qt_("Preferences")) { setupUi(this); @@ -3647,8 +3627,6 @@ bool GuiPreferences::initialiseParams(string const &) converters_.update(formats_); movers_ = theMovers(); colors_.clear(); - update_screen_font_ = false; - update_previews_ = false; updateRC(rc_); // Make sure that the bc is in the INITIAL state @@ -3682,24 +3660,10 @@ void GuiPreferences::dispatchParams() theMovers() = movers_; - vector::const_iterator it = colors_.begin(); - vector::const_iterator const end = colors_.end(); - for (; it != end; ++it) - dispatch(FuncRequest(LFUN_SET_COLOR, *it)); + for (string const & color : colors_) + dispatch(FuncRequest(LFUN_SET_COLOR, color)); colors_.clear(); - if (update_screen_font_) { - dispatch(FuncRequest(LFUN_SCREEN_FONT_UPDATE)); - // resets flag in case second apply in same dialog - update_screen_font_ = false; - } - - if (update_previews_) { - // resets flag in case second apply in same dialog - theBufferList().updatePreviews(); - update_previews_ = false; - } - // Save permanently if (!tempSaveCB->isChecked()) dispatch(FuncRequest(LFUN_PREFERENCES_SAVE)); @@ -3712,18 +3676,6 @@ void GuiPreferences::setColor(ColorCode col, QString const & hex) } -void GuiPreferences::updateScreenFonts() -{ - update_screen_font_ = true; -} - - -void GuiPreferences::updatePreviews() -{ - update_previews_ = true; -} - - QString GuiPreferences::browsebind(QString const & file) const { return browseLibFile("bind", file, "bind", qt_("Choose bind file"), diff --git a/src/frontends/qt4/GuiPrefs.h b/src/frontends/qt4/GuiPrefs.h index b36f2e60c3..4f877a1a0a 100644 --- a/src/frontends/qt4/GuiPrefs.h +++ b/src/frontends/qt4/GuiPrefs.h @@ -98,12 +98,6 @@ public: /// set a color void setColor(ColorCode col, QString const & hex); - /// update the screen fonts after change - void updateScreenFonts(); - - /// update the previews after change - void updatePreviews(); - LyXRC & rc() { return rc_; } Converters & converters() { return converters_; } Formats & formats() { return formats_; } @@ -124,9 +118,6 @@ private: /// A list of colors to be dispatched std::vector colors_; - - bool update_screen_font_; - bool update_previews_; }; diff --git a/status.23x b/status.23x index e21ebf9836..5243604d9f 100644 --- a/status.23x +++ b/status.23x @@ -116,10 +116,10 @@ What's new - Fix some display problems in the Text Properties dialog (bug 11385). -- Accept/reject changes inside selection only if there are changes (bug +- Accept/reject changes inside selection only if there are changes (bug 10338). -- Fix missing TOC update (and related bugs) when setting default master (bug +- Fix missing TOC update (and related bugs) when setting default master (bug 11422). - Properly update bibliography information (with bibliography environment) @@ -154,6 +154,8 @@ What's new - Fix many drawing glitches in the IPA icons. +- Fix crash when disabling math preview (bug 11498). + * INTERNALS -- 2.39.5