[Libreoffice-commits] core.git: 3 commits - compilerplugins/clang include/vcl sc/source sw/inc sw/source vcl/source
Noel Grandin
noel at peralex.com
Wed May 13 03:21:47 PDT 2015
compilerplugins/clang/vclwidgets.cxx | 33 +++++++++++++++++++--------------
include/vcl/lazydelete.hxx | 18 +++++++++---------
sc/source/ui/pagedlg/scuitphfedit.cxx | 2 +-
sc/source/ui/pagedlg/tphfedit.cxx | 2 +-
sw/inc/viewsh.hxx | 10 +++++-----
sw/source/core/view/viewsh.cxx | 2 +-
sw/source/uibase/inc/view.hxx | 16 ++++++++--------
sw/source/uibase/uiview/view.cxx | 7 ++++---
vcl/source/helper/lazydelete.cxx | 4 ++--
vcl/source/window/window.cxx | 4 ++--
10 files changed, 52 insertions(+), 46 deletions(-)
New commits:
commit 4eb16dab21e3e6f47e899060e28ccc515e47316f
Author: Noel Grandin <noel at peralex.com>
Date: Wed May 13 12:16:55 2015 +0200
wrap some static fields in VclPtr
Change-Id: I2df0929d1b34b9ebf2d5d4c27321abdea072007a
diff --git a/sc/source/ui/pagedlg/scuitphfedit.cxx b/sc/source/ui/pagedlg/scuitphfedit.cxx
index f7063f8..6de4ed6 100644
--- a/sc/source/ui/pagedlg/scuitphfedit.cxx
+++ b/sc/source/ui/pagedlg/scuitphfedit.cxx
@@ -51,7 +51,7 @@
// STATIC DATA -----------------------------------------------------------
-static ScEditWindow* pActiveEdWnd = NULL;
+static VclPtr<ScEditWindow> pActiveEdWnd = NULL;
// class ScHFEditPage
diff --git a/sc/source/ui/pagedlg/tphfedit.cxx b/sc/source/ui/pagedlg/tphfedit.cxx
index a01a89f..cb6d90b 100644
--- a/sc/source/ui/pagedlg/tphfedit.cxx
+++ b/sc/source/ui/pagedlg/tphfedit.cxx
@@ -48,7 +48,7 @@
#include <boost/scoped_ptr.hpp>
// STATIC DATA -----------------------------------------------------------
-static ScEditWindow* pActiveEdWnd = NULL;
+static VclPtr<ScEditWindow> pActiveEdWnd = NULL;
ScEditWindow* GetScEditWindow ()
{
diff --git a/sw/inc/viewsh.hxx b/sw/inc/viewsh.hxx
index fb1f9c7..fee06ba 100644
--- a/sw/inc/viewsh.hxx
+++ b/sw/inc/viewsh.hxx
@@ -187,8 +187,8 @@ class SW_DLLPUBLIC SwViewShell : public sw::Ring<SwViewShell>
SAL_DLLPRIVATE void ImplApplyViewOptions( const SwViewOption &rOpt );
protected:
- static ShellResource* mpShellRes; ///< Resources for the Shell.
- static vcl::Window* mpCareWindow; ///< Avoid this window.
+ static ShellResource* mpShellRes; ///< Resources for the Shell.
+ static VclPtr<vcl::Window> mpCareWindow; ///< Avoid this window.
SwRect maVisArea; ///< The modern version of VisArea.
SwDoc *mpDoc; ///< The document; never 0.
@@ -440,9 +440,9 @@ public:
static ShellResource* GetShellRes();
static void SetCareWin( vcl::Window* pNew );
- static vcl::Window* GetCareWin(SwViewShell& rVSh)
- { return mpCareWindow ? mpCareWindow : CareChildWin(rVSh); }
- static vcl::Window* CareChildWin(SwViewShell& rVSh);
+ static vcl::Window* GetCareWin(SwViewShell& rVSh)
+ { return mpCareWindow ? mpCareWindow.get() : CareChildWin(rVSh); }
+ static vcl::Window* CareChildWin(SwViewShell& rVSh);
inline SfxViewShell *GetSfxViewShell() { return mpSfxViewShell; }
inline void SetSfxViewShell(SfxViewShell *pNew) { mpSfxViewShell = pNew; }
diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx
index c9b92fb..7d5495c 100644
--- a/sw/source/core/view/viewsh.cxx
+++ b/sw/source/core/view/viewsh.cxx
@@ -85,7 +85,7 @@
bool SwViewShell::mbLstAct = false;
ShellResource *SwViewShell::mpShellRes = 0;
-vcl::Window *SwViewShell::mpCareWindow = 0;
+VclPtr<vcl::Window> SwViewShell::mpCareWindow = nullptr;
BitmapEx* SwViewShell::mpErrorBmp = NULL;
BitmapEx* SwViewShell::mpReplaceBmp = NULL;
diff --git a/sw/source/uibase/inc/view.hxx b/sw/source/uibase/inc/view.hxx
index 6f0cec2..c89d330 100644
--- a/sw/source/uibase/inc/view.hxx
+++ b/sw/source/uibase/inc/view.hxx
@@ -153,14 +153,14 @@ class SW_DLLPUBLIC SwView: public SfxViewShell
friend class SwClipboardChangeListener;
// search & replace
- static SvxSearchDialog *m_pSrchDlg;
- static SvxSearchItem *m_pSrchItem;
-
- static sal_uInt16 m_nInsertCtrlState;
- static sal_uInt16 m_nWebInsertCtrlState;
- static sal_uInt16 m_nInsertObjectCtrlState;
- static sal_uInt16 m_nInsertFieldCtrlState;
- static sal_uInt16 m_nMoveType; // for buttons below the scrollbar (viewmdi)
+ static VclPtr<SvxSearchDialog> m_pSrchDlg;
+ static SvxSearchItem *m_pSrchItem;
+
+ static sal_uInt16 m_nInsertCtrlState;
+ static sal_uInt16 m_nWebInsertCtrlState;
+ static sal_uInt16 m_nInsertObjectCtrlState;
+ static sal_uInt16 m_nInsertFieldCtrlState;
+ static sal_uInt16 m_nMoveType; // for buttons below the scrollbar (viewmdi)
static sal_Int32 m_nActMark; // current jump mark for unknown mark
static bool m_bExtra;
diff --git a/sw/source/uibase/uiview/view.cxx b/sw/source/uibase/uiview/view.cxx
index 5a15803..02c00d7 100644
--- a/sw/source/uibase/uiview/view.cxx
+++ b/sw/source/uibase/uiview/view.cxx
@@ -36,6 +36,7 @@
#include <sfx2/printer.hxx>
#include <sfx2/app.hxx>
#include <svx/ruler.hxx>
+#include <svx/srchdlg.hxx>
#include <editeng/protitem.hxx>
#include <svx/fmshell.hxx>
#include <svx/extrusionbar.hxx>
@@ -135,9 +136,9 @@ bool SwView::m_bExtra = false;
bool SwView::m_bFound = false;
bool SwView::m_bJustOpened = false;
-SvxSearchDialog* SwView::m_pSrchDlg = 0;
-SearchAttrItemList* SwView::m_pSrchList = 0;
-SearchAttrItemList* SwView::m_pReplList = 0;
+VclPtr<SvxSearchDialog> SwView::m_pSrchDlg = nullptr;
+SearchAttrItemList* SwView::m_pSrchList = 0;
+SearchAttrItemList* SwView::m_pReplList = 0;
inline SfxDispatcher &SwView::GetDispatcher()
{
commit 6850e9b855d3d367ae51111e48cbdb2c28000424
Author: Noel Grandin <noel at peralex.com>
Date: Wed May 13 10:51:30 2015 +0200
first step towards removing LazyDeletor
convert it from a template to a concrete class, since we only have one
use-site for it anyway
Change-Id: I7209243cc744c7ddb727d6136795d8628b91ff6f
diff --git a/include/vcl/lazydelete.hxx b/include/vcl/lazydelete.hxx
index ccefc62..2b746a8 100644
--- a/include/vcl/lazydelete.hxx
+++ b/include/vcl/lazydelete.hxx
@@ -22,6 +22,7 @@
#include <vcl/dllapi.h>
#include <vcl/vclptr.hxx>
+#include <vcl/window.hxx>
#include <unordered_map>
#include <vector>
@@ -95,14 +96,13 @@ namespace vcl
virtual ~LazyDeletorBase();
};
- template < typename T >
class VCL_DLLPUBLIC LazyDeletor : public LazyDeletorBase
{
- static LazyDeletor< T >* s_pOneInstance;
+ static LazyDeletor* s_pOneInstance;
struct DeleteObjectEntry
{
- VclPtr<T> m_pObject;
+ VclPtr<vcl::Window> m_pObject;
bool m_bDeleted;
DeleteObjectEntry() :
@@ -110,7 +110,7 @@ namespace vcl
m_bDeleted( false )
{}
- DeleteObjectEntry( T* i_pObject ) :
+ DeleteObjectEntry( vcl::Window* i_pObject ) :
m_pObject( i_pObject ),
m_bDeleted( false )
{}
@@ -123,7 +123,7 @@ namespace vcl
/** strict weak ordering function to bring objects to be destroyed lazily
in correct order, e.g. for Window objects children before parents
*/
- static bool is_less( T* left, T* right );
+ static bool is_less( vcl::Window* left, vcl::Window* right );
LazyDeletor() { LazyDelete::addDeletor( this ); }
virtual ~LazyDeletor()
@@ -137,7 +137,7 @@ namespace vcl
// do the actual work
unsigned int nCount = m_aObjects.size();
- std::vector< VclPtr < T > > aRealDelete;
+ std::vector< VclPtr < vcl::Window > > aRealDelete;
aRealDelete.reserve( nCount );
for( unsigned int i = 0; i < nCount; i++ )
{
@@ -167,10 +167,10 @@ namespace vcl
public:
/** mark an object for lazy deletion
*/
- static void Delete( T* i_pObject )
+ static void Delete( vcl::Window* i_pObject )
{
if( s_pOneInstance == NULL )
- s_pOneInstance = new LazyDeletor<T>();
+ s_pOneInstance = new LazyDeletor();
// is this object already in the list ?
// if so mark it as not to be deleted; else insert it
@@ -187,7 +187,7 @@ namespace vcl
}
/** unmark an object already marked for lazy deletion
*/
- static void Undelete( T* i_pObject )
+ static void Undelete( vcl::Window* i_pObject )
{
if( s_pOneInstance )
{
diff --git a/vcl/source/helper/lazydelete.cxx b/vcl/source/helper/lazydelete.cxx
index 2594ad4..3b79b5f 100644
--- a/vcl/source/helper/lazydelete.cxx
+++ b/vcl/source/helper/lazydelete.cxx
@@ -33,7 +33,7 @@ LazyDeletorBase::~LazyDeletorBase()
}
// instantiate instance pointer for LazyDeletor<Window>
-template<> LazyDeletor<vcl::Window>* LazyDeletor<vcl::Window>::s_pOneInstance = NULL;
+LazyDeletor* LazyDeletor::s_pOneInstance = NULL;
// a list for all LazyeDeletor<T> singletons
static std::vector< LazyDeletorBase* > lcl_aDeletors;
@@ -54,7 +54,7 @@ void LazyDelete::flush()
}
// specialized is_less function for Window
-template<> bool LazyDeletor<vcl::Window>::is_less( vcl::Window* left, vcl::Window* right )
+bool LazyDeletor::is_less( vcl::Window* left, vcl::Window* right )
{
return left != right && right->IsChild( left, true );
}
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index 1b95b9a..4a589c3 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -578,7 +578,7 @@ void Window::dispose()
Window::~Window()
{
// FIXME: we should kill all LazyDeletor usage.
- vcl::LazyDeletor<vcl::Window>::Undelete( this );
+ vcl::LazyDeletor::Undelete( this );
disposeOnce();
}
@@ -1892,7 +1892,7 @@ void Window::doLazyDelete()
Show( false );
SetParent( ImplGetDefaultWindow() );
}
- vcl::LazyDeletor<vcl::Window>::Delete( this );
+ vcl::LazyDeletor::Delete( this );
}
KeyIndicatorState Window::GetIndicatorState() const
commit 274c836cf82ce3929141e03a28cfb840f4c724cb
Author: Noel Grandin <noel at peralex.com>
Date: Tue May 12 13:30:32 2015 +0200
check for static fields that needs to be wrapped in VclPtr
Change-Id: I6135cfd9aa70f90d58150733b6b48525e5c347c8
diff --git a/compilerplugins/clang/vclwidgets.cxx b/compilerplugins/clang/vclwidgets.cxx
index a09f8db..22d722c 100644
--- a/compilerplugins/clang/vclwidgets.cxx
+++ b/compilerplugins/clang/vclwidgets.cxx
@@ -228,23 +228,10 @@ bool VCLWidgets::VisitVarDecl(const VarDecl * pVarDecl) {
if (ignoreLocation(pVarDecl)) {
return true;
}
- const RecordType *recordType = pVarDecl->getType()->getAs<RecordType>();
- if (recordType == nullptr) {
- return true;
- }
- const CXXRecordDecl *recordDecl = dyn_cast<CXXRecordDecl>(recordType->getDecl());
- if (recordDecl == nullptr) {
+ if ( isa<ParmVarDecl>(pVarDecl) || pVarDecl->isLocalVarDecl() ) {
return true;
}
- // check if this field is derived from Window
- if (isDerivedFromWindow(recordDecl)) {
- report(
- DiagnosticsEngine::Warning,
- "OutputDevice subclass allocated on stack, should be allocated via VclPtr or via *.",
- pVarDecl->getLocation())
- << pVarDecl->getSourceRange();
- }
if ( !startsWith(pVarDecl->getType().getAsString(), "std::vector<vcl::Window *>")
&& !startsWith(pVarDecl->getType().getAsString(), "std::map<vcl::Window *, Size>")
&& !startsWith(pVarDecl->getType().getAsString(), "std::map<vcl::Window *, class Size>")
@@ -270,6 +257,24 @@ bool VCLWidgets::VisitVarDecl(const VarDecl * pVarDecl) {
"OutputDevice subclass should be wrapped in VclPtr. " + pVarDecl->getType().getAsString(),
pVarDecl->getLocation())
<< pVarDecl->getSourceRange();
+ return true;
+ }
+
+ const RecordType *recordType = pVarDecl->getType()->getAs<RecordType>();
+ if (recordType == nullptr) {
+ return true;
+ }
+ const CXXRecordDecl *recordDecl = dyn_cast<CXXRecordDecl>(recordType->getDecl());
+ if (recordDecl == nullptr) {
+ return true;
+ }
+ // check if this field is derived from Window
+ if (isDerivedFromWindow(recordDecl)) {
+ report(
+ DiagnosticsEngine::Warning,
+ "OutputDevice subclass allocated on stack, should be allocated via VclPtr or via *.",
+ pVarDecl->getLocation())
+ << pVarDecl->getSourceRange();
}
return true;
}
More information about the Libreoffice-commits
mailing list