mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
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:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -101,6 +101,7 @@ class ChangeSetStyleAction : public DisplayChangeAction {
|
||||
Set& set; ///< The affected set
|
||||
CardP card; ///< The card whos stylesheet is copied to the set
|
||||
StyleSheetP stylesheet; ///< The old stylesheet of the set
|
||||
vector<int> has_styling; ///< The old has_styling values of all cards (vector<bool> is evil)
|
||||
};
|
||||
|
||||
/// Changing the styling of a card to become custom/non-custom
|
||||
|
||||
+3
-1
@@ -41,7 +41,9 @@ class Card : public IntrusivePtrVirtualBase {
|
||||
/** Optional; if not set use the card style from the set */
|
||||
StyleSheetP stylesheet;
|
||||
/// Alternative options to use for this card, for this card's stylesheet
|
||||
/** Optional; if not set use the styling data from the set */
|
||||
/** Optional; if not set use the styling data from the set.
|
||||
* If stylesheet is set then contains data for the this->stylesheet, otherwise for set->stylesheet
|
||||
*/
|
||||
IndexMap<FieldP,ValueP> styling_data;
|
||||
/// Is the styling_data set?
|
||||
bool has_styling;
|
||||
|
||||
Reference in New Issue
Block a user