compilerplugins/clang/badstatics.cxx           |    4 ++--
 sc/inc/colorscale.hxx                          |    6 +++++-
 sc/inc/document.hxx                            |    5 +++++
 sc/source/core/data/colorscale.cxx             |   11 +++++------
 sc/source/core/data/documen2.cxx               |   10 ++++++++++
 sc/source/ui/condformat/condformatdlgentry.cxx |    2 +-
 sc/source/ui/view/output.cxx                   |   20 +++++++++++---------
 sd/source/ui/tools/IconCache.cxx               |   14 +++++++-------
 vcl/source/app/scheduler.cxx                   |   13 ++++++++++++-
 vcl/source/gdi/impimagetree.cxx                |    4 ++--
 10 files changed, 60 insertions(+), 29 deletions(-)

New commits:
commit 526bfba0a0ef5cfa213b2c978eed83e43bb3cd9a
Author: Michael Stahl <[email protected]>
Date:   Tue Nov 17 23:43:26 2015 +0100

    vcl, sd: rename some overly generic static variables
    
    Change-Id: I89159df36361f9ceff3401ef379c8230465617b7

diff --git a/compilerplugins/clang/badstatics.cxx 
b/compilerplugins/clang/badstatics.cxx
index 3b2881f..394c33e 100644
--- a/compilerplugins/clang/badstatics.cxx
+++ b/compilerplugins/clang/badstatics.cxx
@@ -136,7 +136,7 @@ public:
                 || name == "g_pHyphIter" // SwEditShell::HyphEnd()
                 || name == "pFieldEditEngine" // ScGlobal::Clear()
                 || name == "xDrawClipDocShellRef" // ScGlobal::Clear()
-                || name == "instance"
+                || name == "s_ImplImageTree"
                     // ImplImageTree::get(), ImplImageTree::shutDown()
                 || name == "s_pMouseFrame"
                     // vcl/osx/salframeview.mm, mouseEntered/Exited, not owning
@@ -146,7 +146,7 @@ public:
                 || name == "s_pCaptureFrame" // vcl/osx/salframe.cxx, not 
owning
                 || name == "pBlink"
                     // sw/source/core/text/blink.cxx, _TextFinit()
-                || name == "mpInstance"
+                || name == "s_pIconCache"
                     // sd/source/ui/tools/IconCache.cxx, leaked
                ) // these variables appear unproblematic
             {
diff --git a/sd/source/ui/tools/IconCache.cxx b/sd/source/ui/tools/IconCache.cxx
index 6c46806..ecc15e1 100644
--- a/sd/source/ui/tools/IconCache.cxx
+++ b/sd/source/ui/tools/IconCache.cxx
@@ -37,7 +37,7 @@ private:
         IconCache::Instance() is called to the end of the sd module when the
         cache is destroyed from SdGlobalResourceContainer.
     */
-    static IconCache* mpInstance;
+    static IconCache* s_pIconCache;
 
     typedef std::unordered_map<sal_uInt16,Image> ImageContainer;
     ImageContainer maContainer;
@@ -45,7 +45,7 @@ private:
     Image GetIcon (sal_uInt16 nResourceId);
 };
 
-IconCache* IconCache::Implementation::mpInstance = nullptr;
+IconCache* IconCache::Implementation::s_pIconCache = nullptr;
 
 Image IconCache::Implementation::GetIcon (sal_uInt16 nResourceId)
 {
@@ -67,17 +67,17 @@ Image IconCache::Implementation::GetIcon (sal_uInt16 
nResourceId)
 //static
 IconCache& IconCache::Instance()
 {
-    if (Implementation::mpInstance == nullptr)
+    if (Implementation::s_pIconCache == nullptr)
     {
         ::osl::GetGlobalMutex aMutexFunctor;
         ::osl::MutexGuard aGuard (aMutexFunctor());
-        if (Implementation::mpInstance == nullptr)
+        if (Implementation::s_pIconCache == nullptr)
         {
             IconCache* pCache = new IconCache ();
             SdGlobalResourceContainer::Instance().AddResource (
                 ::std::unique_ptr<SdGlobalResource>(pCache));
             OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
-            Implementation::mpInstance = pCache;
+            Implementation::s_pIconCache = pCache;
         }
     }
     else
@@ -85,9 +85,9 @@ IconCache& IconCache::Instance()
         OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
     }
 
-    DBG_ASSERT(Implementation::mpInstance!=nullptr,
+    DBG_ASSERT(Implementation::s_pIconCache != nullptr,
         "IconCache::Instance(): instance is NULL");
-    return *Implementation::mpInstance;
+    return *Implementation::s_pIconCache;
 }
 
 Image IconCache::GetIcon (sal_uInt16 nResourceId)
diff --git a/vcl/source/gdi/impimagetree.cxx b/vcl/source/gdi/impimagetree.cxx
index 0a8d1a5..6726673 100644
--- a/vcl/source/gdi/impimagetree.cxx
+++ b/vcl/source/gdi/impimagetree.cxx
@@ -100,8 +100,8 @@ static void loadImageFromStream(std::shared_ptr<SvStream> 
xStream, OUString cons
 }
 
 ImplImageTree & ImplImageTree::get() {
-    static ImplImageTree instance;
-    return instance;
+    static ImplImageTree s_ImplImageTree;
+    return s_ImplImageTree;
 }
 
 ImplImageTree::ImplImageTree()
commit f324e507acf2875ac12d6ab1c1fca4fe95ba1817
Author: Michael Stahl <[email protected]>
Date:   Tue Nov 17 23:01:54 2015 +0100

    vcl: avoid re-starting the WNT TimerQueue during shutdown
    
    When running CppunitTest_sc_macros_test in DrMemory, numerous
    unaddressable accesses from SalTimerProc are reported.
    
    During DeInitVCL(), ImplSalStopTimer() shuts down the TimerQueue, but
    then the problem is that some disposing of some sidebar related UNO
    service ends up calling Window::dispose() and Window::Hide() and
    Window::ImplPostPaint(), which starts an Idle job maPaintIdle
    that then re-starts the Win32 TimerQueue.
    
    Change-Id: Ie1ab14330b6f1002c12d5302bb19f2b3f4c3811d

diff --git a/vcl/source/app/scheduler.cxx b/vcl/source/app/scheduler.cxx
index 9e43a932..6092f1d 100644
--- a/vcl/source/app/scheduler.cxx
+++ b/vcl/source/app/scheduler.cxx
@@ -114,6 +114,12 @@ void Scheduler::ImplDeInitScheduler()
 void Scheduler::ImplStartTimer(sal_uInt64 nMS, bool bForce)
 {
     ImplSVData* pSVData = ImplGetSVData();
+    if (pSVData->mbDeInit)
+    {
+        // do not start new timers during shutdown - if that happens after
+        // ImplSalStopTimer() on WNT the timer queue is restarted and never 
ends
+        return;
+    }
     InitSystemTimer(pSVData);
 
     if ( !nMS )
@@ -215,10 +221,15 @@ void Scheduler::ProcessTaskScheduling( bool bTimer )
 
 void Scheduler::Start()
 {
+    ImplSVData *const pSVData = ImplGetSVData();
+    if (pSVData->mbDeInit)
+    {
+        return;
+    }
+
     // Mark timer active
     mbActive = true;
 
-    ImplSVData* pSVData = ImplGetSVData();
     if ( !mpSchedulerData )
     {
         // insert Scheduler
commit 05896a16412dd48d19ffd2e360ae7da5e41c2725
Author: Michael Stahl <[email protected]>
Date:   Tue Nov 17 22:33:28 2015 +0100

    sc: loplugin:badstatics
    
    Not sure if there would be a performance penalty to re-loading these
    icons every time, so move the static map from
    ScIconSetFormat::getBitmap() to a member of ScDocument.
    
    Change-Id: If560d70cea27e25396dd821d9e77a785e3b79820

diff --git a/sc/inc/colorscale.hxx b/sc/inc/colorscale.hxx
index a593e4d..427bf53 100644
--- a/sc/inc/colorscale.hxx
+++ b/sc/inc/colorscale.hxx
@@ -30,6 +30,10 @@ struct ScDataBarInfo;
 class BitmapEx;
 class ScFormulaListener;
 
+namespace sc {
+    class IconSetBitmapMap : public std::map<sal_Int32, BitmapEx> {};
+}
+
 // don't change the order
 // they are also used in the dialog to determine the position
 // in the list box
@@ -375,7 +379,7 @@ public:
     virtual condformat::ScFormatEntryType GetType() const override;
 
     static ScIconSetMap* getIconSetMap();
-    static BitmapEx& getBitmap( ScIconSetType eType, sal_Int32 nIndex );
+    static BitmapEx& getBitmap(sc::IconSetBitmapMap &, ScIconSetType eType, 
sal_Int32 nIndex);
 
     typedef ScIconSetFormatData::Entries_t::iterator iterator;
     typedef ScIconSetFormatData::Entries_t::const_iterator const_iterator;
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 1fc5d2d..72a2d2d 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -79,6 +79,7 @@ class RefMovedHint;
 struct SortUndoParam;
 struct ReorderParam;
 class FormulaGroupAreaListener;
+class IconSetBitmapMap;
 
 }
 
@@ -467,6 +468,8 @@ private:
 
     bool                mbUseEmbedFonts;
 
+    std::unique_ptr<sc::IconSetBitmapMap> m_pIconSetBitmapMap;
+
 public:
     bool IsCellInChangeTrack(const ScAddress &cell,Color *pColCellBoder);
     void GetCellChangeTrackNote(const ScAddress &cell, OUString &strTrackText, 
bool &pbLeftEdge);
@@ -1872,6 +1875,8 @@ public:
 
     std::set<Color> GetDocColors();
 
+    sc::IconSetBitmapMap& GetIconSetBitmapMap();
+
 private:
     ScDocument(const ScDocument& r) = delete;
 
diff --git a/sc/source/core/data/colorscale.cxx 
b/sc/source/core/data/colorscale.cxx
index 2fc9a64..42904e1 100644
--- a/sc/source/core/data/colorscale.cxx
+++ b/sc/source/core/data/colorscale.cxx
@@ -1333,10 +1333,9 @@ static const ScIconSetBitmapMap aBitmapMap[] = {
 
 }
 
-BitmapEx& ScIconSetFormat::getBitmap( ScIconSetType eType, sal_Int32 nIndex )
+BitmapEx& ScIconSetFormat::getBitmap(sc::IconSetBitmapMap & rIconSetBitmapMap,
+        ScIconSetType const eType, sal_Int32 const nIndex)
 {
-    static std::map< sal_Int32, BitmapEx > aIconSetBitmaps;
-
     sal_Int32 nBitmap = -1;
 
     for(size_t i = 0; i < SAL_N_ELEMENTS(aBitmapMap); ++i)
@@ -1349,13 +1348,13 @@ BitmapEx& ScIconSetFormat::getBitmap( ScIconSetType 
eType, sal_Int32 nIndex )
     }
     assert( nBitmap != -1 );
 
-    std::map<sal_Int32, BitmapEx>::iterator itr = aIconSetBitmaps.find( 
nBitmap );
-    if(itr != aIconSetBitmaps.end())
+    std::map<sal_Int32, BitmapEx>::iterator itr = 
rIconSetBitmapMap.find(nBitmap);
+    if (itr != rIconSetBitmapMap.end())
         return itr->second;
 
     BitmapEx aBitmap = BitmapEx(ScResId(nBitmap));
     std::pair<sal_Int32, BitmapEx> aPair( nBitmap, aBitmap );
-    std::pair<std::map<sal_Int32, BitmapEx>::iterator, bool> itrNew = 
aIconSetBitmaps.insert(aPair);
+    std::pair<std::map<sal_Int32, BitmapEx>::iterator, bool> itrNew = 
rIconSetBitmapMap.insert(aPair);
     assert(itrNew.second);
 
     return itrNew.first->second;
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index d0a960e..dd554ec 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -1406,4 +1406,14 @@ ScStyleSheet* ScDocument::GetPreviewCellStyle( SCCOL 
nCol, SCROW nRow, SCTAB nTa
         pRet = pPreviewCellStyle;
     return pRet;
 }
+
+sc::IconSetBitmapMap& ScDocument::GetIconSetBitmapMap()
+{
+    if (!m_pIconSetBitmapMap)
+    {
+        m_pIconSetBitmapMap.reset(new sc::IconSetBitmapMap);
+    }
+    return *m_pIconSetBitmapMap;
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/condformat/condformatdlgentry.cxx 
b/sc/source/ui/condformat/condformatdlgentry.cxx
index 059fbb5..51c0a6b 100644
--- a/sc/source/ui/condformat/condformatdlgentry.cxx
+++ b/sc/source/ui/condformat/condformatdlgentry.cxx
@@ -1418,7 +1418,7 @@ ScIconSetFrmtDataEntry::ScIconSetFrmtDataEntry( 
vcl::Window* pParent, ScIconSetT
     maEdEntry( VclPtr<Edit>::Create( this, ScResId( ED_ICON_SET_ENTRY_VALUE ) 
) ),
     maLbEntryType( VclPtr<ListBox>::Create( this, ScResId( 
LB_ICON_SET_ENTRY_TYPE ) ) )
 {
-    maImgIcon->SetImage(Image(ScIconSetFormat::getBitmap(eType, i)));
+    
maImgIcon->SetImage(Image(ScIconSetFormat::getBitmap(pDoc->GetIconSetBitmapMap(),
 eType, i)));
     if(pEntry)
     {
         switch(pEntry->GetType())
diff --git a/sc/source/ui/view/output.cxx b/sc/source/ui/view/output.cxx
index 12970ce..16e2499 100644
--- a/sc/source/ui/view/output.cxx
+++ b/sc/source/ui/view/output.cxx
@@ -873,24 +873,26 @@ void drawDataBars(vcl::RenderContext& rRenderContext, 
const ScDataBarInfo* pOldD
     }
 }
 
-BitmapEx& getIcon( ScIconSetType eType, sal_Int32 nIndex )
+BitmapEx& getIcon(sc::IconSetBitmapMap & rIconSetBitmapMap, ScIconSetType 
eType, sal_Int32 nIndex)
 {
-    return ScIconSetFormat::getBitmap( eType, nIndex );
+    return ScIconSetFormat::getBitmap(rIconSetBitmapMap, eType, nIndex);
 }
 
-void drawIconSets(vcl::RenderContext& rRenderContext, const ScIconSetInfo* 
pOldIconSetInfo, const Rectangle& rRect, long nOneX, long nOneY)
+void drawIconSets(vcl::RenderContext& rRenderContext, const ScIconSetInfo* 
pOldIconSetInfo, const Rectangle& rRect, long nOneX, long nOneY,
+        sc::IconSetBitmapMap & rIconSetBitmapMap)
 {
     //long nSize = 16;
     ScIconSetType eType = pOldIconSetInfo->eIconSetType;
     sal_Int32 nIndex = pOldIconSetInfo->nIconIndex;
-    BitmapEx& rIcon = getIcon( eType, nIndex );
+    BitmapEx& rIcon = getIcon(rIconSetBitmapMap, eType, nIndex);
     long aOrigSize = std::max<long>(0,std::min(rRect.GetSize().getWidth() - 4 
* nOneX, rRect.GetSize().getHeight() -4 * nOneY));
     rRenderContext.DrawBitmapEx( Point( rRect.Left() + 2 * nOneX, rRect.Top() 
+ 2 * nOneY), Size(aOrigSize, aOrigSize), rIcon );
 }
 
 void drawCells(vcl::RenderContext& rRenderContext, const Color* pColor, const 
SvxBrushItem* pBackground, const Color*& pOldColor, const SvxBrushItem*& 
pOldBackground,
         Rectangle& rRect, long nPosX, long nLayoutSign, long nOneX, long 
nOneY, const ScDataBarInfo* pDataBarInfo, const ScDataBarInfo*& pOldDataBarInfo,
-        const ScIconSetInfo* pIconSetInfo, const ScIconSetInfo*& 
pOldIconSetInfo)
+        const ScIconSetInfo* pIconSetInfo, const ScIconSetInfo*& 
pOldIconSetInfo,
+        sc::IconSetBitmapMap & rIconSetBitmapMap)
 {
     long nSignedOneX = nOneX * nLayoutSign;
     // need to paint if old color scale has been used and now
@@ -907,7 +909,7 @@ void drawCells(vcl::RenderContext& rRenderContext, const 
Color* pColor, const Sv
         if( pOldDataBarInfo )
             drawDataBars(rRenderContext, pOldDataBarInfo, rRect, nOneX, nOneY);
         if( pOldIconSetInfo )
-            drawIconSets(rRenderContext, pOldIconSetInfo, rRect, nOneX, nOneY);
+            drawIconSets(rRenderContext, pOldIconSetInfo, rRect, nOneX, nOneY, 
rIconSetBitmapMap);
 
         rRect.Left() = nPosX - nSignedOneX;
     }
@@ -927,7 +929,7 @@ void drawCells(vcl::RenderContext& rRenderContext, const 
Color* pColor, const Sv
         if( pOldDataBarInfo )
             drawDataBars(rRenderContext, pOldDataBarInfo, rRect, nOneX, nOneY);
         if( pOldIconSetInfo )
-            drawIconSets(rRenderContext, pOldIconSetInfo, rRect, nOneX, nOneY);
+            drawIconSets(rRenderContext, pOldIconSetInfo, rRect, nOneX, nOneY, 
rIconSetBitmapMap);
 
         rRect.Left() = nPosX - nSignedOneX;
     }
@@ -1087,7 +1089,7 @@ void ScOutputData::DrawBackground(vcl::RenderContext& 
rRenderContext)
                     if (bWorksInPixels)
                         nPosXLogic = rRenderContext.PixelToLogic(Point(nPosX, 
0)).X();
 
-                    drawCells(rRenderContext, pColor, pBackground, pOldColor, 
pOldBackground, aRect, nPosXLogic, nLayoutSign, nOneXLogic, nOneYLogic, 
pDataBarInfo, pOldDataBarInfo, pIconSetInfo, pOldIconSetInfo);
+                    drawCells(rRenderContext, pColor, pBackground, pOldColor, 
pOldBackground, aRect, nPosXLogic, nLayoutSign, nOneXLogic, nOneYLogic, 
pDataBarInfo, pOldDataBarInfo, pIconSetInfo, pOldIconSetInfo, 
mpDoc->GetIconSetBitmapMap());
 
                     // extend for all merged cells
                     nMergedCells = 1;
@@ -1111,7 +1113,7 @@ void ScOutputData::DrawBackground(vcl::RenderContext& 
rRenderContext)
                 if (bWorksInPixels)
                     nPosXLogic = rRenderContext.PixelToLogic(Point(nPosX, 
0)).X();
 
-                drawCells(rRenderContext, nullptr, nullptr, pOldColor, 
pOldBackground, aRect, nPosXLogic, nLayoutSign, nOneXLogic, nOneYLogic, 
nullptr, pOldDataBarInfo, nullptr, pOldIconSetInfo);
+                drawCells(rRenderContext, nullptr, nullptr, pOldColor, 
pOldBackground, aRect, nPosXLogic, nLayoutSign, nOneXLogic, nOneYLogic, 
nullptr, pOldDataBarInfo, nullptr, pOldIconSetInfo, 
mpDoc->GetIconSetBitmapMap());
 
                 nArrY += nSkip;
             }
_______________________________________________
Libreoffice-commits mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to