From 8aea747b8875e8cb0c529294318e150a35d26620 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Fri, 18 Apr 2014 18:59:45 -0700 Subject: [PATCH] Update the character counter synchronously It's not longer even vaguely in the realm of slow enough to justify dumping off on a background thread. --- src/subs_edit_box.cpp | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/subs_edit_box.cpp b/src/subs_edit_box.cpp index 3c264bb6a..6204084c7 100644 --- a/src/subs_edit_box.cpp +++ b/src/subs_edit_box.cpp @@ -54,7 +54,6 @@ #include "video_context.h" #include -#include #include #include @@ -586,15 +585,11 @@ void SubsEditBox::CallCommand(const char *cmd_name) { void SubsEditBox::UpdateCharacterCount(std::string const& text) { auto ignore_whitespace = OPT_GET("Subtitle/Character Counter/Ignore Whitespace")->GetBool(); - agi::dispatch::Background().Async([=]{ - size_t length = agi::MaxLineLength(text, ignore_whitespace); - agi::dispatch::Main().Async([=]{ - char_count->SetValue(wxString::Format("%lu", (unsigned long)length)); - size_t limit = (size_t)OPT_GET("Subtitle/Character Limit")->GetInt(); - if (limit && length > limit) - char_count->SetBackgroundColour(to_wx(OPT_GET("Colour/Subtitle/Syntax/Background/Error")->GetColor())); - else - char_count->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); - }); - }); + size_t length = agi::MaxLineLength(text, ignore_whitespace); + char_count->SetValue(wxString::Format("%lu", (unsigned long)length)); + size_t limit = (size_t)OPT_GET("Subtitle/Character Limit")->GetInt(); + if (limit && length > limit) + char_count->SetBackgroundColour(to_wx(OPT_GET("Colour/Subtitle/Syntax/Background/Error")->GetColor())); + else + char_count->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); }