From 709dc31f7865573cbf23c09dbd1946b017e7dc80 Mon Sep 17 00:00:00 2001 From: robnee Date: Sun, 25 Apr 2021 09:24:35 -0400 Subject: [PATCH] Fix lookup of stipple pattern before config is available Fix a bug with the lookup of stipple pattern for default styles when the config settings are not yet available (install/upgrade/first run). This caused hidden lines to display as continuous rather than dashed. --- src/sketch.h | 1 + src/style.cpp | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/sketch.h b/src/sketch.h index bda0a983..74111d18 100644 --- a/src/sketch.h +++ b/src/sketch.h @@ -924,6 +924,7 @@ public: static double StippleScale(hStyle hs); static double StippleScaleMm(hStyle hs); static std::string StipplePatternName(hStyle hs); + static std::string StipplePatternName(StipplePattern stippleType); static StipplePattern StipplePatternFromString(std::string name); std::string DescriptionString() const; diff --git a/src/style.cpp b/src/style.cpp index b4ed841e..b1070cdc 100644 --- a/src/style.cpp +++ b/src/style.cpp @@ -114,7 +114,8 @@ void Style::FillDefaultStyle(Style *s, const Default *d, bool factory) { s->stippleType = (factory) ? d->stippleType : Style::StipplePatternFromString( - settings->ThawString(CnfStippleType(d->cnfPrefix), "")); + settings->ThawString(CnfStippleType(d->cnfPrefix), + StipplePatternName(d->stippleType))); s->stippleScale = (factory) ? 15.0 : settings->ThawFloat(CnfStippleScale(d->cnfPrefix), 15.0); @@ -397,7 +398,11 @@ StipplePattern Style::PatternType(hStyle hs) { std::string Style::StipplePatternName(hStyle hs) { Style *s = Get(hs); - switch(s->stippleType) { + return StipplePatternName(s->stippleType); +} + +std::string Style::StipplePatternName(StipplePattern stippleType) { + switch(stippleType) { case StipplePattern::CONTINUOUS: return "Continuous"; case StipplePattern::SHORT_DASH: return "ShortDash"; case StipplePattern::DASH: return "Dash"; @@ -409,10 +414,9 @@ std::string Style::StipplePatternName(hStyle hs) { case StipplePattern::ZIGZAG: return "ZigZag"; } - return "CONTINUOUS"; + return "Continuous"; } - double Style::StippleScale(hStyle hs) { Style *s = Get(hs); return s->stippleScale;