include/xmloff/prstylei.hxx      |    6 -
 xmloff/source/style/prstylei.cxx |  135 ++++++++++++++++++++++-----------------
 2 files changed, 78 insertions(+), 63 deletions(-)

New commits:
commit 49bbea41a2371bb9fb5a585a2efec61bd82a92c5
Author: Noel Grandin <n...@peralex.com>
Date:   Tue Aug 23 13:55:35 2016 +0200

    use rtl::Static for static std::ordered_set in XMLPropStyleContext
    
    we suspect the current situation of causing a crash on shutdown after
    the tokenmap unit test:
    
    (gdb) bt 20
    __gnu_cxx::new_allocator<std::__detail::_Hash_node_base*>::deallocate
    (this=0x7fffffff52c7, __p=0x78a700)
        at
    /opt/rh/devtoolset-2/root/usr/include/c++/4.8.2/ext/new_allocator.h:110
    std::allocator<rtl::OUString>, std::__detail::_Identity,
    std::equal_to<rtl::OUString>, rtl::OUStringHash,
    std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash,
    std::__detail::_Prime_rehash_policy,
    std::__detail::_Hashtable_traits<true, true, true>
    >::_M_deallocate_buckets (
        this=0x2aaab3166640 <XMLPropStyleContext::maParaSet>, __p=0x78a700,
    __n=11) at
    /opt/rh/devtoolset-2/root/usr/include/c++/4.8.2/bits/hashtable.h:794
    std::allocator<rtl::OUString>, std::__detail::_Identity,
    std::equal_to<rtl::OUString>, rtl::OUStringHash,
    std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash,
    std::__detail::_Prime_rehash_policy,
    std::__detail::_Hashtable_traits<true, true, true> >::~_Hashtable (
        this=0x2aaab3166640 <XMLPropStyleContext::maParaSet>,
    __in_chrg=<optimized out>) at
    /opt/rh/devtoolset-2/root/usr/include/c++/4.8.2/bits/hashtable.h:959
    rtl::OUStringHash, std::equal_to<rtl::OUString>,
    std::allocator<rtl::OUString> >::~unordered_set (
        this=0x2aaab3166640 <XMLPropStyleContext::maParaSet>,
    __in_chrg=<optimized out>) at
    /opt/rh/devtoolset-2/root/usr/include/c++/4.8.2/bits/unordered_set.h:93
    rtl::OUStringHash, std::equal_to<rtl::OUString>,
    std::allocator<rtl::OUString> >::~unordered_set (
        this=0x2aaab3166640 <XMLPropStyleContext::maParaSet>,
    __in_chrg=<optimized out>) at
    /opt/rh/devtoolset-2/root/usr/include/c++/4.8.2/debug/unordered_set:113
    
    Change-Id: Iff36d4f217b8bb07083d2e599afade1f86206165

diff --git a/include/xmloff/prstylei.hxx b/include/xmloff/prstylei.hxx
index da5278c..081ba36 100644
--- a/include/xmloff/prstylei.hxx
+++ b/include/xmloff/prstylei.hxx
@@ -48,12 +48,6 @@ private:
     css::uno::Reference < css::style::XStyle > mxStyle;
     SvXMLImportContextRef                      mxStyles;
 
-    //UUUU
-    static OldFillStyleDefinitionSet maStandardSet;
-    static OldFillStyleDefinitionSet maHeaderSet;
-    static OldFillStyleDefinitionSet maFooterSet;
-    static OldFillStyleDefinitionSet maParaSet;
-
     XMLPropStyleContext(XMLPropStyleContext &) = delete;
     void operator =(XMLPropStyleContext &) = delete;
 
diff --git a/xmloff/source/style/prstylei.cxx b/xmloff/source/style/prstylei.cxx
index 9aa121b..5900230 100644
--- a/xmloff/source/style/prstylei.cxx
+++ b/xmloff/source/style/prstylei.cxx
@@ -71,11 +71,80 @@ void XMLPropStyleContext::SetAttribute( sal_uInt16 
nPrefixKey,
 }
 
 
-//UUUU
-OldFillStyleDefinitionSet XMLPropStyleContext::maStandardSet;
-OldFillStyleDefinitionSet XMLPropStyleContext::maHeaderSet;
-OldFillStyleDefinitionSet XMLPropStyleContext::maFooterSet;
-OldFillStyleDefinitionSet XMLPropStyleContext::maParaSet;
+namespace
+{
+    struct theStandardSet :
+        public rtl::StaticWithInit<OldFillStyleDefinitionSet, theStandardSet>
+    {
+        OldFillStyleDefinitionSet operator () ()
+        {
+            OldFillStyleDefinitionSet aSet;
+            aSet.insert("BackColorRGB");
+            aSet.insert("BackTransparent");
+            aSet.insert("BackColorTransparency");
+            aSet.insert("BackGraphicURL");
+            aSet.insert("BackGraphicFilter");
+            aSet.insert("BackGraphicLocation");
+            aSet.insert("BackGraphicTransparency");
+            return aSet;
+        }
+    };
+    struct theHeaderSet :
+        public rtl::StaticWithInit<OldFillStyleDefinitionSet, theHeaderSet>
+    {
+        OldFillStyleDefinitionSet operator () ()
+        {
+            OldFillStyleDefinitionSet aSet;
+            aSet.insert("HeaderBackColorRGB");
+            aSet.insert("HeaderBackTransparent");
+            aSet.insert("HeaderBackColorTransparency");
+            aSet.insert("HeaderBackGraphicURL");
+            aSet.insert("HeaderBackGraphicFilter");
+            aSet.insert("HeaderBackGraphicLocation");
+            aSet.insert("HeaderBackGraphicTransparency");
+            return aSet;
+        }
+    };
+    struct theFooterSet :
+        public rtl::StaticWithInit<OldFillStyleDefinitionSet, theFooterSet>
+    {
+        OldFillStyleDefinitionSet operator () ()
+        {
+            OldFillStyleDefinitionSet aSet;
+            aSet.insert("FooterBackColorRGB");
+            aSet.insert("FooterBackTransparent");
+            aSet.insert("FooterBackColorTransparency");
+            aSet.insert("FooterBackGraphicURL");
+            aSet.insert("FooterBackGraphicFilter");
+            aSet.insert("FooterBackGraphicLocation");
+            aSet.insert("FooterBackGraphicTransparency");
+            return aSet;
+        }
+    };
+    struct theParaSet :
+        public rtl::StaticWithInit<OldFillStyleDefinitionSet, theParaSet>
+    {
+        OldFillStyleDefinitionSet operator () ()
+        {
+            OldFillStyleDefinitionSet aSet;
+            // Caution: here it is *not* 'ParaBackColorRGB' as it should be, 
but indeed
+            // 'ParaBackColor' is used, see aXMLParaPropMap definition (line 
313)
+            aSet.insert("ParaBackColor");
+            aSet.insert("ParaBackTransparent");
+            aSet.insert("ParaBackGraphicLocation");
+            aSet.insert("ParaBackGraphicFilter");
+            aSet.insert("ParaBackGraphicURL");
+
+            // These are not used in aXMLParaPropMap definition, thus not 
needed here
+            // aSet.insert("ParaBackColorTransparency");
+            // aSet.insert("ParaBackGraphicTransparency");
+            return aSet;
+        }
+    };
+}
+
+
+
 
 XMLPropStyleContext::XMLPropStyleContext( SvXMLImport& rImport,
         sal_uInt16 nPrfx, const OUString& rLName,
@@ -95,70 +164,22 @@ XMLPropStyleContext::~XMLPropStyleContext()
 
 const OldFillStyleDefinitionSet& XMLPropStyleContext::getStandardSet()
 {
-    if(maStandardSet.empty())
-    {
-        maStandardSet.insert("BackColorRGB");
-        maStandardSet.insert("BackTransparent");
-        maStandardSet.insert("BackColorTransparency");
-        maStandardSet.insert("BackGraphicURL");
-        maStandardSet.insert("BackGraphicFilter");
-        maStandardSet.insert("BackGraphicLocation");
-        maStandardSet.insert("BackGraphicTransparency");
-    }
-
-    return maStandardSet;
+    return theStandardSet::get();
 }
 
 const OldFillStyleDefinitionSet& XMLPropStyleContext::getHeaderSet()
 {
-    if(maHeaderSet.empty())
-    {
-        maHeaderSet.insert("HeaderBackColorRGB");
-        maHeaderSet.insert("HeaderBackTransparent");
-        maHeaderSet.insert("HeaderBackColorTransparency");
-        maHeaderSet.insert("HeaderBackGraphicURL");
-        maHeaderSet.insert("HeaderBackGraphicFilter");
-        maHeaderSet.insert("HeaderBackGraphicLocation");
-        maHeaderSet.insert("HeaderBackGraphicTransparency");
-    }
-
-    return maHeaderSet;
+    return theHeaderSet::get();
 }
 
 const OldFillStyleDefinitionSet& XMLPropStyleContext::getFooterSet()
 {
-    if(maFooterSet.empty())
-    {
-        maFooterSet.insert("FooterBackColorRGB");
-        maFooterSet.insert("FooterBackTransparent");
-        maFooterSet.insert("FooterBackColorTransparency");
-        maFooterSet.insert("FooterBackGraphicURL");
-        maFooterSet.insert("FooterBackGraphicFilter");
-        maFooterSet.insert("FooterBackGraphicLocation");
-        maFooterSet.insert("FooterBackGraphicTransparency");
-    }
-
-    return maFooterSet;
+    return theFooterSet::get();
 }
 
 const OldFillStyleDefinitionSet& XMLPropStyleContext::getParaSet()
 {
-    if(maParaSet.empty())
-    {
-        // Caution: here it is *not* 'ParaBackColorRGB' as it should be, but 
indeed
-        // 'ParaBackColor' is used, see aXMLParaPropMap definition (line 313)
-        maParaSet.insert("ParaBackColor");
-        maParaSet.insert("ParaBackTransparent");
-        maParaSet.insert("ParaBackGraphicLocation");
-        maParaSet.insert("ParaBackGraphicFilter");
-        maParaSet.insert("ParaBackGraphicURL");
-
-        // These are not used in aXMLParaPropMap definition, thus not needed 
here
-        // maParaSet.insert("ParaBackColorTransparency");
-        // maParaSet.insert("ParaBackGraphicTransparency");
-    }
-
-    return maParaSet;
+    return theParaSet::get();
 }
 
 SvXMLImportContext *XMLPropStyleContext::CreateChildContext(
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to