[Libreoffice-commits] core.git: Branch 'feature/vclref' - 2 commits - compilerplugins/clang include/vcl vcl/source

Noel Grandin noel at peralex.com
Thu Jan 8 00:41:17 PST 2015


 compilerplugins/clang/passstuffbyref.cxx |    3 ++-
 include/vcl/edit.hxx                     |    2 +-
 include/vcl/layout.hxx                   |    8 ++++----
 vcl/source/control/edit.cxx              |    2 +-
 vcl/source/window/layout.cxx             |   10 +++++-----
 5 files changed, 13 insertions(+), 12 deletions(-)

New commits:
commit 6a124a1dd629cfeec35a5820ed62e0d138b00302
Author: Noel Grandin <noel at peralex.com>
Date:   Thu Jan 8 10:38:15 2015 +0200

    vcl: plugin: check that VclPtr is passed by reference
    
    to avoid unnecessary increment/decrement traffic
    
    Change-Id: Ice4e08df002b815105aa0b1c9430511c0cec3d28

diff --git a/compilerplugins/clang/passstuffbyref.cxx b/compilerplugins/clang/passstuffbyref.cxx
index 51e324a..e233093 100644
--- a/compilerplugins/clang/passstuffbyref.cxx
+++ b/compilerplugins/clang/passstuffbyref.cxx
@@ -58,6 +58,7 @@ bool PassStuffByRef::VisitFunctionDecl(const FunctionDecl * functionDecl) {
         bool bFound = false;
         if (typeName == "class rtl::OUString" ||
             typeName == "class rtl::OString" ||
+            typeName.find("class VclPtr") == 0 ||
             typeName.find("class com::sun::star::uno::Sequence") == 0) {
             bFound = true;
         }
@@ -75,7 +76,7 @@ bool PassStuffByRef::VisitFunctionDecl(const FunctionDecl * functionDecl) {
         if (bFound) {
             report(
                 DiagnosticsEngine::Warning,
-                "passing " + typeName + " by value, rather pass by reference .e.g. 'const " + typeName + "&'",
+                "passing " + typeName + " by value, rather pass by const reference .e.g. 'const " + typeName + "&'",
                 pvDecl->getSourceRange().getBegin())
               << pvDecl->getSourceRange();
         }
diff --git a/include/vcl/edit.hxx b/include/vcl/edit.hxx
index ff9d2a0..59d1ce0 100644
--- a/include/vcl/edit.hxx
+++ b/include/vcl/edit.hxx
@@ -236,7 +236,7 @@ public:
     virtual const Link& GetModifyHdl() const { return maModifyHdl; }
     virtual void        SetUpdateDataHdl( const Link& rLink ) { maUpdateDataHdl = rLink; }
 
-    void                SetSubEdit( VclPtr<Edit> pEdit );
+    void                SetSubEdit( const VclPtr<Edit>& pEdit );
     Edit*               GetSubEdit() const { return mpSubEdit; }
 
     boost::signals2::signal< void ( Edit* ) > autocompleteSignal;
diff --git a/vcl/source/control/edit.cxx b/vcl/source/control/edit.cxx
index ab3b1f0..3f17870 100644
--- a/vcl/source/control/edit.cxx
+++ b/vcl/source/control/edit.cxx
@@ -2706,7 +2706,7 @@ void Edit::ClearModifyFlag()
         mbModified = false;
 }
 
-void Edit::SetSubEdit( VclPtr<Edit> pEdit )
+void Edit::SetSubEdit( const VclPtr<Edit>& pEdit )
 {
     mpSubEdit.disposeAndClear();
     mpSubEdit = pEdit;
commit ded247661f2200d703c71377a6f83d9a3480958a
Author: Noel Grandin <noel at peralex.com>
Date:   Thu Jan 8 10:29:24 2015 +0200

    vcl: a couple more places that shouldn't be stack-allocating Window objects
    
    Change-Id: I773fb5ed066db2c22b3d50198dff350b755ab24a

diff --git a/include/vcl/layout.hxx b/include/vcl/layout.hxx
index ed84144..7df6fe0 100644
--- a/include/vcl/layout.hxx
+++ b/include/vcl/layout.hxx
@@ -577,7 +577,7 @@ private:
     bool m_bUserManagedScrolling;
     VclPtr<ScrollBar> m_pVScroll;
     VclPtr<ScrollBar> m_pHScroll;
-    ScrollBarBox m_aScrollBarBox;
+    VclPtr<ScrollBarBox> m_aScrollBarBox;
 };
 
 class VCL_DLLPUBLIC VclViewport : public VclBin
@@ -619,13 +619,13 @@ private:
         }
     };
 
-    EventBoxHelper m_aEventBoxHelper;
+    VclPtr<EventBoxHelper> m_aEventBoxHelper;
 public:
     VclEventBox(vcl::Window* pParent)
         : VclBin(pParent)
-        , m_aEventBoxHelper(this)
+        , m_aEventBoxHelper(new EventBoxHelper(this))
     {
-        m_aEventBoxHelper.Show();
+        m_aEventBoxHelper->Show();
     }
     virtual vcl::Window *get_child() SAL_OVERRIDE;
     virtual const vcl::Window *get_child() const SAL_OVERRIDE;
diff --git a/vcl/source/window/layout.cxx b/vcl/source/window/layout.cxx
index 107c6a2..64688e5 100644
--- a/vcl/source/window/layout.cxx
+++ b/vcl/source/window/layout.cxx
@@ -1612,7 +1612,7 @@ VclScrolledWindow::VclScrolledWindow(vcl::Window *pParent, WinBits nStyle)
     , m_bUserManagedScrolling(false)
     , m_pVScroll(new ScrollBar(this, WB_HIDE | WB_VERT))
     , m_pHScroll(new ScrollBar(this, WB_HIDE | WB_HORZ))
-    , m_aScrollBarBox(this, WB_HIDE)
+    , m_aScrollBarBox(new ScrollBarBox(this, WB_HIDE))
 {
     SetType(WINDOW_SCROLLWINDOW);
 
@@ -1764,12 +1764,12 @@ void VclScrolledWindow::setAllocation(const Size &rAllocation)
     if (m_pVScroll->IsVisible() && m_pHScroll->IsVisible())
     {
         Point aBoxPos(aInnerSize.Width(), aInnerSize.Height());
-        m_aScrollBarBox.SetPosSizePixel(aBoxPos, Size(nScrollBarWidth, nScrollBarHeight));
-        m_aScrollBarBox.Show();
+        m_aScrollBarBox->SetPosSizePixel(aBoxPos, Size(nScrollBarWidth, nScrollBarHeight));
+        m_aScrollBarBox->Show();
     }
     else
     {
-        m_aScrollBarBox.Hide();
+        m_aScrollBarBox->Hide();
     }
 
     if (pChild && pChild->IsVisible())
@@ -1835,7 +1835,7 @@ const vcl::Window *VclEventBox::get_child() const
 {
     const WindowImpl* pWindowImpl = ImplGetWindowImpl();
 
-    assert(pWindowImpl->mpFirstChild == &m_aEventBoxHelper);
+    assert(pWindowImpl->mpFirstChild == m_aEventBoxHelper.get());
 
     return pWindowImpl->mpFirstChild->GetWindow(WINDOW_NEXT);
 }


More information about the Libreoffice-commits mailing list