Commit cbbd1ca5 authored by twanvl's avatar twanvl

Fixed possible crash bug with card specific style options. By changing the set...

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.
parent 3d313a37
......@@ -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
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment