From 8513fef7e26a733d32936eeacbddc1f3d5c32c60 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Sat, 2 Jan 2010 06:23:02 +0000 Subject: [PATCH] Eliminate an unnecessary call to VideoContext::UpdateDisplays triggered by SubsEditBox::SetToLine, moderately improving responsiveness when working with lines that take a long time to render. Originally committed to SVN as r3925. --- aegisub/src/subs_edit_box.cpp | 17 ++++++++++------- aegisub/src/subs_edit_box.h | 2 +- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/aegisub/src/subs_edit_box.cpp b/aegisub/src/subs_edit_box.cpp index 7ce778637..1825891c1 100644 --- a/aegisub/src/subs_edit_box.cpp +++ b/aegisub/src/subs_edit_box.cpp @@ -261,10 +261,11 @@ void SubsEditBox::SetSplitLineMode(wxSize newSize) { /// @brief Update function -/// @param timeOnly -/// @param weak +/// @param timeOnly If true, only update the time fields +/// @param weak ? +/// @param video If true, update the video display /// -void SubsEditBox::Update (bool timeOnly,bool weak) { +void SubsEditBox::Update (bool timeOnly,bool weak,bool video) { if (enabled) { AssDialogue *curdiag = grid->GetDialogue(linen); if (curdiag) { @@ -300,7 +301,7 @@ void SubsEditBox::Update (bool timeOnly,bool weak) { // Video VideoContext::Get()->curLine = curdiag; - VideoContext::Get()->UpdateDisplays(false); + if (video) VideoContext::Get()->UpdateDisplays(false); TextEdit->EmptyUndoBuffer(); } @@ -352,10 +353,12 @@ void SubsEditBox::SetToLine(int n,bool weak) { // Set to nothing if (n == -1) { enabled = false; + SetControlsState(false); + return; } // Set line - else if (grid->GetDialogue(n)) { + if (grid->GetDialogue(n)) { enabled = true; if (n != linen) { linen = n; @@ -366,7 +369,7 @@ void SubsEditBox::SetToLine(int n,bool weak) { } // Update controls - Update(); + Update(false, false, false); // Set video if (VideoContext::Get()->IsLoaded() && !weak) { @@ -374,7 +377,7 @@ void SubsEditBox::SetToLine(int n,bool weak) { if (Search.hasFocus) sync = _T("Find update video"); else sync = _T("Sync video with subs"); - if (Options.AsBool(sync) == true) { + if (Options.AsBool(sync)) { VideoContext::Get()->Stop(); AssDialogue *cur = grid->GetDialogue(n); if (cur) VideoContext::Get()->JumpToFrame(VFR_Output.GetFrameAtTime(cur->Start.GetMS(),true)); diff --git a/aegisub/src/subs_edit_box.h b/aegisub/src/subs_edit_box.h index 68b5951b2..96e62a6a5 100644 --- a/aegisub/src/subs_edit_box.h +++ b/aegisub/src/subs_edit_box.h @@ -251,7 +251,7 @@ public: void SetSplitLineMode(wxSize size=wxSize(-1,-1)); void CommitText(bool weak=false); - void Update(bool timeOnly=false,bool weak=false); + void Update(bool timeOnly=false,bool weak=false,bool video=true); void UpdateGlobals(); void SetToLine(int n,bool weak=false); void UpdateFrameTiming();