Needed to call updatedata when changing style name. Also, add some error handling to pasting styles.

Originally committed to SVN as r1551.
This commit is contained in:
Dan Donovan 2007-09-02 19:31:17 +00:00
parent a5aa4245f0
commit c5a91a11fe
1 changed files with 36 additions and 16 deletions

View File

@ -689,16 +689,26 @@ void DialogStyleManager::PasteToCurrent() {
wxStringTokenizer st(data,_T('\n')); wxStringTokenizer st(data,_T('\n'));
while (st.HasMoreTokens()) { while (st.HasMoreTokens()) {
AssStyle *s = new AssStyle(st.GetNextToken().Trim(true)); try {
if (s->Valid) { AssStyle *s = new AssStyle(st.GetNextToken().Trim(true));
while (AssFile::top->GetStyle(s->name) != NULL) if (s->Valid) {
s->name = _T("Copy of ") + s->name; while (AssFile::top->GetStyle(s->name) != NULL)
s->name = _T("Copy of ") + s->name;
AssFile::top->InsertStyle(s); s->UpdateData();
LoadCurrentStyles(AssFile::top); AssFile::top->InsertStyle(s);
LoadCurrentStyles(AssFile::top);
grid->ass->FlagAsModified(_("style paste"));
grid->CommitChanges();
}
else
wxMessageBox(_("Could not parse style"), _("Could not parse style"), wxOK | wxICON_EXCLAMATION , this);
} }
grid->ass->FlagAsModified(_("style paste")); catch (...) {
grid->CommitChanges(); wxMessageBox(_("Could not parse style"), _("Could not parse style"), wxOK | wxICON_EXCLAMATION , this);
}
} }
} }
void DialogStyleManager::PasteToStorage() { void DialogStyleManager::PasteToStorage() {
@ -715,16 +725,26 @@ void DialogStyleManager::PasteToStorage() {
wxStringTokenizer st(data,_T('\n')); wxStringTokenizer st(data,_T('\n'));
while (st.HasMoreTokens()) { while (st.HasMoreTokens()) {
AssStyle *s = new AssStyle(st.GetNextToken().Trim(true)); try {
if (s->Valid) { AssStyle *s = new AssStyle(st.GetNextToken().Trim(true));
while (Store.GetStyle(s->name) != NULL) if (s->Valid) {
s->name = _T("Copy of ") + s->name; while (Store.GetStyle(s->name) != NULL)
s->name = _T("Copy of ") + s->name;
Store.style.push_back(s); s->UpdateData();
Store.Save(CatalogList->GetString(CatalogList->GetSelection())); Store.style.push_back(s);
Store.Save(CatalogList->GetString(CatalogList->GetSelection()));
LoadStorageStyles();
StorageList->SetStringSelection(s->name);
}
else
wxMessageBox(_("Could not parse style"), _("Could not parse style"), wxOK | wxICON_EXCLAMATION , this);
} }
LoadStorageStyles(); catch(...) {
StorageList->SetStringSelection(s->name); wxMessageBox(_("Could not parse style"), _("Could not parse style"), wxOK | wxICON_EXCLAMATION , this);
}
} }
} }
/////////////// ///////////////