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.
This commit is contained in:
Thomas Goyne 2010-01-02 06:23:02 +00:00
parent 931326e3c0
commit 8513fef7e2
2 changed files with 11 additions and 8 deletions

View File

@ -261,10 +261,11 @@ void SubsEditBox::SetSplitLineMode(wxSize newSize) {
/// @brief Update function /// @brief Update function
/// @param timeOnly /// @param timeOnly If true, only update the time fields
/// @param weak /// @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) { if (enabled) {
AssDialogue *curdiag = grid->GetDialogue(linen); AssDialogue *curdiag = grid->GetDialogue(linen);
if (curdiag) { if (curdiag) {
@ -300,7 +301,7 @@ void SubsEditBox::Update (bool timeOnly,bool weak) {
// Video // Video
VideoContext::Get()->curLine = curdiag; VideoContext::Get()->curLine = curdiag;
VideoContext::Get()->UpdateDisplays(false); if (video) VideoContext::Get()->UpdateDisplays(false);
TextEdit->EmptyUndoBuffer(); TextEdit->EmptyUndoBuffer();
} }
@ -352,10 +353,12 @@ void SubsEditBox::SetToLine(int n,bool weak) {
// Set to nothing // Set to nothing
if (n == -1) { if (n == -1) {
enabled = false; enabled = false;
SetControlsState(false);
return;
} }
// Set line // Set line
else if (grid->GetDialogue(n)) { if (grid->GetDialogue(n)) {
enabled = true; enabled = true;
if (n != linen) { if (n != linen) {
linen = n; linen = n;
@ -366,7 +369,7 @@ void SubsEditBox::SetToLine(int n,bool weak) {
} }
// Update controls // Update controls
Update(); Update(false, false, false);
// Set video // Set video
if (VideoContext::Get()->IsLoaded() && !weak) { if (VideoContext::Get()->IsLoaded() && !weak) {
@ -374,7 +377,7 @@ void SubsEditBox::SetToLine(int n,bool weak) {
if (Search.hasFocus) sync = _T("Find update video"); if (Search.hasFocus) sync = _T("Find update video");
else sync = _T("Sync video with subs"); else sync = _T("Sync video with subs");
if (Options.AsBool(sync) == true) { if (Options.AsBool(sync)) {
VideoContext::Get()->Stop(); VideoContext::Get()->Stop();
AssDialogue *cur = grid->GetDialogue(n); AssDialogue *cur = grid->GetDialogue(n);
if (cur) VideoContext::Get()->JumpToFrame(VFR_Output.GetFrameAtTime(cur->Start.GetMS(),true)); if (cur) VideoContext::Get()->JumpToFrame(VFR_Output.GetFrameAtTime(cur->Start.GetMS(),true));

View File

@ -251,7 +251,7 @@ public:
void SetSplitLineMode(wxSize size=wxSize(-1,-1)); void SetSplitLineMode(wxSize size=wxSize(-1,-1));
void CommitText(bool weak=false); 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 UpdateGlobals();
void SetToLine(int n,bool weak=false); void SetToLine(int n,bool weak=false);
void UpdateFrameTiming(); void UpdateFrameTiming();