Use wxEventBlocker rather than manually enabling and disabling the event handler in SubsEditBox
Originally committed to SVN as r6133.
This commit is contained in:
parent
e5707ca6eb
commit
046d8a6822
1 changed files with 6 additions and 17 deletions
|
@ -334,7 +334,7 @@ SubsEditBox::~SubsEditBox() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SubsEditBox::Update(int type) {
|
void SubsEditBox::Update(int type) {
|
||||||
SetEvtHandlerEnabled(false);
|
wxEventBlocker blocker(this);
|
||||||
|
|
||||||
if (type == AssFile::COMMIT_NEW || type & AssFile::COMMIT_STYLES) {
|
if (type == AssFile::COMMIT_NEW || type & AssFile::COMMIT_STYLES) {
|
||||||
StyleBox->Clear();
|
StyleBox->Clear();
|
||||||
|
@ -346,7 +346,6 @@ void SubsEditBox::Update(int type) {
|
||||||
PopulateActorList();
|
PopulateActorList();
|
||||||
|
|
||||||
TextEdit->SetSelection(0,0);
|
TextEdit->SetSelection(0,0);
|
||||||
SetEvtHandlerEnabled(true);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (type & AssFile::COMMIT_STYLES)
|
else if (type & AssFile::COMMIT_STYLES)
|
||||||
|
@ -355,10 +354,7 @@ void SubsEditBox::Update(int type) {
|
||||||
if (!(type ^ AssFile::COMMIT_ORDER)) return;
|
if (!(type ^ AssFile::COMMIT_ORDER)) return;
|
||||||
|
|
||||||
SetControlsState(!!line);
|
SetControlsState(!!line);
|
||||||
if (!line) {
|
if (!line) return;
|
||||||
SetEvtHandlerEnabled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (type & AssFile::COMMIT_DIAG_TIME) {
|
if (type & AssFile::COMMIT_DIAG_TIME) {
|
||||||
StartTime->SetTime(line->Start);
|
StartTime->SetTime(line->Start);
|
||||||
|
@ -383,11 +379,11 @@ void SubsEditBox::Update(int type) {
|
||||||
ActorBox->ChangeValue(line->Actor.empty() ? "Actor" : line->Actor);
|
ActorBox->ChangeValue(line->Actor.empty() ? "Actor" : line->Actor);
|
||||||
ActorBox->SetStringSelection(line->Actor);
|
ActorBox->SetStringSelection(line->Actor);
|
||||||
}
|
}
|
||||||
|
|
||||||
SetEvtHandlerEnabled(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SubsEditBox::PopulateActorList() {
|
void SubsEditBox::PopulateActorList() {
|
||||||
|
wxEventBlocker blocker(this);
|
||||||
|
|
||||||
std::set<wxString> actors;
|
std::set<wxString> actors;
|
||||||
for (entryIter it = c->ass->Line.begin(); it != c->ass->Line.end(); ++it) {
|
for (entryIter it = c->ass->Line.begin(); it != c->ass->Line.end(); ++it) {
|
||||||
if (AssDialogue *diag = dynamic_cast<AssDialogue*>(*it))
|
if (AssDialogue *diag = dynamic_cast<AssDialogue*>(*it))
|
||||||
|
@ -403,8 +399,6 @@ void SubsEditBox::PopulateActorList() {
|
||||||
copy(actors.begin(), actors.end(), std::back_inserter(arrstr));
|
copy(actors.begin(), actors.end(), std::back_inserter(arrstr));
|
||||||
|
|
||||||
ActorBox->Freeze();
|
ActorBox->Freeze();
|
||||||
bool evt_handler_was_enabled = GetEvtHandlerEnabled();
|
|
||||||
SetEvtHandlerEnabled(false);
|
|
||||||
long pos = ActorBox->GetInsertionPoint();
|
long pos = ActorBox->GetInsertionPoint();
|
||||||
wxString value = ActorBox->GetValue();
|
wxString value = ActorBox->GetValue();
|
||||||
|
|
||||||
|
@ -413,14 +407,11 @@ void SubsEditBox::PopulateActorList() {
|
||||||
ActorBox->ChangeValue(value);
|
ActorBox->ChangeValue(value);
|
||||||
ActorBox->SetStringSelection(value);
|
ActorBox->SetStringSelection(value);
|
||||||
ActorBox->SetInsertionPoint(pos);
|
ActorBox->SetInsertionPoint(pos);
|
||||||
|
|
||||||
if (evt_handler_was_enabled)
|
|
||||||
SetEvtHandlerEnabled(true);
|
|
||||||
ActorBox->Thaw();
|
ActorBox->Thaw();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SubsEditBox::OnActiveLineChanged(AssDialogue *new_line) {
|
void SubsEditBox::OnActiveLineChanged(AssDialogue *new_line) {
|
||||||
SetEvtHandlerEnabled(false);
|
wxEventBlocker blocker(this);
|
||||||
line = new_line;
|
line = new_line;
|
||||||
|
|
||||||
Update(AssFile::COMMIT_DIAG_FULL);
|
Update(AssFile::COMMIT_DIAG_FULL);
|
||||||
|
@ -436,7 +427,6 @@ void SubsEditBox::OnActiveLineChanged(AssDialogue *new_line) {
|
||||||
c->videoController->JumpToTime(line->Start);
|
c->videoController->JumpToTime(line->Start);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SetEvtHandlerEnabled(true);
|
|
||||||
}
|
}
|
||||||
void SubsEditBox::OnSelectedSetChanged(const Selection &, const Selection &) {
|
void SubsEditBox::OnSelectedSetChanged(const Selection &, const Selection &) {
|
||||||
sel = c->selectionController->GetSelectedSet();
|
sel = c->selectionController->GetSelectedSet();
|
||||||
|
@ -608,7 +598,7 @@ void SubsEditBox::SetControlsState(bool state) {
|
||||||
ToggableButtons[i]->Enable(state);
|
ToggableButtons[i]->Enable(state);
|
||||||
|
|
||||||
if (!state) {
|
if (!state) {
|
||||||
SetEvtHandlerEnabled(false);
|
wxEventBlocker blocker(this);
|
||||||
TextEdit->SetTextTo("");
|
TextEdit->SetTextTo("");
|
||||||
StartTime->SetTime(0);
|
StartTime->SetTime(0);
|
||||||
EndTime->SetTime(0);
|
EndTime->SetTime(0);
|
||||||
|
@ -619,7 +609,6 @@ void SubsEditBox::SetControlsState(bool state) {
|
||||||
MarginV->ChangeValue("");
|
MarginV->ChangeValue("");
|
||||||
Effect->ChangeValue("");
|
Effect->ChangeValue("");
|
||||||
CommentBox->SetValue(false);
|
CommentBox->SetValue(false);
|
||||||
SetEvtHandlerEnabled(true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue