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.
This commit is contained in:
Thomas Goyne 2014-04-18 18:59:45 -07:00
parent 2de95818db
commit 8aea747b88
1 changed files with 7 additions and 12 deletions

View File

@ -54,7 +54,6 @@
#include "video_context.h" #include "video_context.h"
#include <libaegisub/character_count.h> #include <libaegisub/character_count.h>
#include <libaegisub/dispatch.h>
#include <libaegisub/util.h> #include <libaegisub/util.h>
#include <functional> #include <functional>
@ -586,15 +585,11 @@ void SubsEditBox::CallCommand(const char *cmd_name) {
void SubsEditBox::UpdateCharacterCount(std::string const& text) { void SubsEditBox::UpdateCharacterCount(std::string const& text) {
auto ignore_whitespace = OPT_GET("Subtitle/Character Counter/Ignore Whitespace")->GetBool(); auto ignore_whitespace = OPT_GET("Subtitle/Character Counter/Ignore Whitespace")->GetBool();
agi::dispatch::Background().Async([=]{
size_t length = agi::MaxLineLength(text, ignore_whitespace); size_t length = agi::MaxLineLength(text, ignore_whitespace);
agi::dispatch::Main().Async([=]{
char_count->SetValue(wxString::Format("%lu", (unsigned long)length)); char_count->SetValue(wxString::Format("%lu", (unsigned long)length));
size_t limit = (size_t)OPT_GET("Subtitle/Character Limit")->GetInt(); size_t limit = (size_t)OPT_GET("Subtitle/Character Limit")->GetInt();
if (limit && length > limit) if (limit && length > limit)
char_count->SetBackgroundColour(to_wx(OPT_GET("Colour/Subtitle/Syntax/Background/Error")->GetColor())); char_count->SetBackgroundColour(to_wx(OPT_GET("Colour/Subtitle/Syntax/Background/Error")->GetColor()));
else else
char_count->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); char_count->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
});
});
} }