Fixed possible crash bug with card specific style options. By changing the set stylesheet it was possible for the option values to be matched with the wrong fields.

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@981 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2008-06-17 17:56:15 +00:00
parent 72864e91cb
commit 83e632f5af
3 changed files with 18 additions and 1 deletions
+14
View File
@@ -14,6 +14,8 @@
#include <util/error.hpp>
DECLARE_TYPEOF_COLLECTION(IndexMap<FieldP COMMA ValueP>);
DECLARE_TYPEOF_COLLECTION(CardP);
DECLARE_TYPEOF_COLLECTION(int);
// ----------------------------------------------------------------------------- : Add card
@@ -95,12 +97,24 @@ String ChangeSetStyleAction::getName(bool to_undo) const {
}
void ChangeSetStyleAction::perform(bool to_undo) {
if (!to_undo) {
// backup has_styling
has_styling.clear();
FOR_EACH(card, set.cards) {
has_styling.push_back(card->has_styling);
if (!card->stylesheet) {
card->has_styling = false; // this card has custom style options for the default stylesheet
}
}
stylesheet = set.stylesheet;
set.stylesheet = card->stylesheet;
card->stylesheet = StyleSheetP();
} else {
card->stylesheet = set.stylesheet;
set.stylesheet = stylesheet;
// restore has_styling
FOR_EACH_2(card, set.cards, has, has_styling) {
card->has_styling = has;
}
}
}