diff options
| author | Rye Mutt <rye@alchemyviewer.org> | 2024-08-13 18:39:57 -0400 | 
|---|---|---|
| committer | Rye Mutt <rye@alchemyviewer.org> | 2024-08-14 00:31:37 -0400 | 
| commit | 2cff1e217ba0df94fc50a30c8d49dc848c294ac6 (patch) | |
| tree | b60df9f75e219d3bad7c975b6acd05cd357b1f05 | |
| parent | ad8dc13150b640ae9613e1edd8cc8c2c72b1e6b2 (diff) | |
Reduce UI draw stalls from LLSpellChecker singleton via simpleton
| -rw-r--r-- | indra/llui/llspellcheck.cpp | 17 | ||||
| -rw-r--r-- | indra/llui/llspellcheck.h | 9 | ||||
| -rw-r--r-- | indra/llui/llui.cpp | 3 | ||||
| -rw-r--r-- | indra/newview/llappviewer.cpp | 29 | 
4 files changed, 27 insertions, 31 deletions
| diff --git a/indra/llui/llspellcheck.cpp b/indra/llui/llspellcheck.cpp index 16ffd352cf..e15616a16b 100644 --- a/indra/llui/llspellcheck.cpp +++ b/indra/llui/llspellcheck.cpp @@ -42,19 +42,13 @@ static const std::string DICT_FILE_USER = "user_dictionaries.xml";  LLSpellChecker::settings_change_signal_t LLSpellChecker::sSettingsChangeSignal;  LLSpellChecker::LLSpellChecker() -    : mHunspell(NULL)  { +    // Load initial dictionary information +    refreshDictionaryMap();  }  LLSpellChecker::~LLSpellChecker()  { -    delete mHunspell; -} - -void LLSpellChecker::initSingleton() -{ -    // Load initial dictionary information -    refreshDictionaryMap();  }  bool LLSpellChecker::checkSpelling(const std::string& word) const @@ -300,8 +294,7 @@ void LLSpellChecker::initHunspell(const std::string& dict_language)  {      if (mHunspell)      { -        delete mHunspell; -        mHunspell = NULL; +        mHunspell.reset();          mDictLanguage.clear();          mDictFile.clear();          mIgnoreList.clear(); @@ -322,11 +315,11 @@ void LLSpellChecker::initHunspell(const std::string& dict_language)          const std::string filename_dic = dict_entry["name"].asString() + ".dic";          if ( (gDirUtilp->fileExists(user_path + filename_aff)) && (gDirUtilp->fileExists(user_path + filename_dic)) )          { -            mHunspell = new Hunspell((user_path + filename_aff).c_str(), (user_path + filename_dic).c_str()); +            mHunspell = std::make_unique<Hunspell>((user_path + filename_aff).c_str(), (user_path + filename_dic).c_str());          }          else if ( (gDirUtilp->fileExists(app_path + filename_aff)) && (gDirUtilp->fileExists(app_path + filename_dic)) )          { -            mHunspell = new Hunspell((app_path + filename_aff).c_str(), (app_path + filename_dic).c_str()); +            mHunspell = std::make_unique<Hunspell>((app_path + filename_aff).c_str(), (app_path + filename_dic).c_str());          }          if (!mHunspell)          { diff --git a/indra/llui/llspellcheck.h b/indra/llui/llspellcheck.h index e4d8a12ef1..9df2f94085 100644 --- a/indra/llui/llspellcheck.h +++ b/indra/llui/llspellcheck.h @@ -34,12 +34,12 @@  class Hunspell; -class LLSpellChecker : public LLSingleton<LLSpellChecker> +class LLSpellChecker : public LLSimpleton<LLSpellChecker>  { -    LLSINGLETON(LLSpellChecker); +public: +    LLSpellChecker();      ~LLSpellChecker(); -public:      void addToCustomDictionary(const std::string& word);      void addToIgnoreList(const std::string& word);      bool checkSpelling(const std::string& word) const; @@ -47,7 +47,6 @@ public:  protected:      void addToDictFile(const std::string& dict_path, const std::string& word);      void initHunspell(const std::string& dict_language); -    void initSingleton() override;  public:      typedef std::list<std::string> dict_list_t; @@ -77,7 +76,7 @@ public:      static boost::signals2::connection setSettingsChangeCallback(const settings_change_signal_t::slot_type& cb);  protected: -    Hunspell*   mHunspell; +    std::unique_ptr<Hunspell>   mHunspell;      std::string mDictLanguage;      std::string mDictFile;      dict_list_t mDictSecondary; diff --git a/indra/llui/llui.cpp b/indra/llui/llui.cpp index 8d46422c09..e36dae3955 100644 --- a/indra/llui/llui.cpp +++ b/indra/llui/llui.cpp @@ -54,6 +54,7 @@  #include "llmenubutton.h"  #include "llloadingindicator.h"  #include "llwindow.h" +#include "llspellcheck.h"  // for registration  #include "llfiltereditor.h" @@ -157,6 +158,7 @@ mRootView(NULL),  mHelpImpl(NULL)  {      LLRender2D::createInstance(image_provider); +    LLSpellChecker::createInstance();      if ((get_ptr_in_map(mSettingGroups, std::string("config")) == NULL) ||          (get_ptr_in_map(mSettingGroups, std::string("floater")) == NULL) || @@ -198,6 +200,7 @@ mHelpImpl(NULL)  LLUI::~LLUI()  { +    LLSpellChecker::deleteSingleton();      LLRender2D::deleteSingleton();  } diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 262ab439b4..36fe5a953f 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -806,6 +806,20 @@ bool LLAppViewer::init()          LLUIImageList::getInstance(),          ui_audio_callback,          deferred_ui_audio_callback); + +    if (gSavedSettings.getBOOL("SpellCheck")) +    { +        std::list<std::string> dict_list; +        std::string dict_setting = gSavedSettings.getString("SpellCheckDictionary"); +        boost::split(dict_list, dict_setting, boost::is_any_of(std::string(","))); +        if (!dict_list.empty()) +        { +            LLSpellChecker::setUseSpellCheck(dict_list.front()); +            dict_list.pop_front(); +            LLSpellChecker::instance().setSecondaryDictionaries(dict_list); +        } +    } +      LL_INFOS("InitInfo") << "UI initialized." << LL_ENDL ;      // NOW LLUI::getLanguage() should work. gDirUtilp must know the language @@ -1611,7 +1625,7 @@ bool LLAppViewer::doFrame()              {                  LL_PROFILE_ZONE_NAMED_CATEGORY_APP("df gMeshRepo"); -            gMeshRepo.update() ; +                gMeshRepo.update() ;              }              if(!total_work_pending) //pause texture fetching threads if nothing to process. @@ -2799,19 +2813,6 @@ bool LLAppViewer::initConfiguration()                                   gSavedSettings.getString("Language"));      } -    if (gSavedSettings.getBOOL("SpellCheck")) -    { -        std::list<std::string> dict_list; -        std::string dict_setting = gSavedSettings.getString("SpellCheckDictionary"); -        boost::split(dict_list, dict_setting, boost::is_any_of(std::string(","))); -        if (!dict_list.empty()) -        { -            LLSpellChecker::setUseSpellCheck(dict_list.front()); -            dict_list.pop_front(); -            LLSpellChecker::instance().setSecondaryDictionaries(dict_list); -        } -    } -      if (gNonInteractive)      {          tempSetControl("AllowMultipleViewers", "true"); | 
