[Libreoffice-commits] core.git: 2 commits - include/sfx2 include/svx include/vcl svx/source sw/source

Noel Grandin noel.grandin at collabora.co.uk
Mon Apr 16 06:21:44 UTC 2018


 include/sfx2/StyleManager.hxx                  |    3 +-
 include/svx/CommonStyleManager.hxx             |    2 -
 include/vcl/pdfwriter.hxx                      |   30 ++++++++++++-------------
 svx/source/styles/CommonStyleManager.cxx       |    4 +--
 sw/source/uibase/sidebar/StylePresetsPanel.cxx |    4 +--
 5 files changed, 22 insertions(+), 21 deletions(-)

New commits:
commit a0b3e81aeb10488c4746360dc1669f3aed71cb67
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Fri Apr 13 16:55:45 2018 +0200

    make StyleManager::CreateStylePreviewRenderer return std::unique_ptr
    
    consequently fixing memory leak in sw/
    
    Change-Id: Id66657cb8310baf42b0475cdef5e3618406974eb
    Reviewed-on: https://gerrit.libreoffice.org/52842
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/include/sfx2/StyleManager.hxx b/include/sfx2/StyleManager.hxx
index 7c3bcfeb1d3f..593da26d7f4c 100644
--- a/include/sfx2/StyleManager.hxx
+++ b/include/sfx2/StyleManager.hxx
@@ -18,6 +18,7 @@
 #include <svl/style.hxx>
 
 #include <sfx2/objsh.hxx>
+#include <memory>
 
 namespace sfx2
 {
@@ -37,7 +38,7 @@ public:
 
     SfxStyleSheetBase* Search(const OUString& rStyleName, SfxStyleFamily eFamily);
 
-    virtual StylePreviewRenderer* CreateStylePreviewRenderer(
+    virtual std::unique_ptr<StylePreviewRenderer> CreateStylePreviewRenderer(
                     OutputDevice& rOutputDev, SfxStyleSheetBase* pStyle,
                     long nMaxHeight) = 0;
 };
diff --git a/include/svx/CommonStyleManager.hxx b/include/svx/CommonStyleManager.hxx
index 7cd8a0a90bd5..261472124596 100644
--- a/include/svx/CommonStyleManager.hxx
+++ b/include/svx/CommonStyleManager.hxx
@@ -28,7 +28,7 @@ public:
         : StyleManager(rShell)
     {}
 
-    virtual sfx2::StylePreviewRenderer* CreateStylePreviewRenderer(
+    virtual std::unique_ptr<sfx2::StylePreviewRenderer> CreateStylePreviewRenderer(
                                             OutputDevice& rOutputDev, SfxStyleSheetBase* pStyle,
                                             long nMaxHeight) override;
 };
diff --git a/svx/source/styles/CommonStyleManager.cxx b/svx/source/styles/CommonStyleManager.cxx
index 2dd825bcecef..e88b97aad7d3 100644
--- a/svx/source/styles/CommonStyleManager.cxx
+++ b/svx/source/styles/CommonStyleManager.cxx
@@ -14,11 +14,11 @@
 namespace svx
 {
 
-sfx2::StylePreviewRenderer* CommonStyleManager::CreateStylePreviewRenderer(
+std::unique_ptr<sfx2::StylePreviewRenderer> CommonStyleManager::CreateStylePreviewRenderer(
                                             OutputDevice& rOutputDev, SfxStyleSheetBase* pStyle,
                                             long nMaxHeight)
 {
-    return new CommonStylePreviewRenderer(mrShell, rOutputDev, pStyle, nMaxHeight);
+    return std::unique_ptr<sfx2::StylePreviewRenderer>(new CommonStylePreviewRenderer(mrShell, rOutputDev, pStyle, nMaxHeight));
 }
 
 } // end svx namespace
diff --git a/sw/source/uibase/sidebar/StylePresetsPanel.cxx b/sw/source/uibase/sidebar/StylePresetsPanel.cxx
index e515ea30f761..aacaa9b5f462 100644
--- a/sw/source/uibase/sidebar/StylePresetsPanel.cxx
+++ b/sw/source/uibase/sidebar/StylePresetsPanel.cxx
@@ -49,8 +49,8 @@ void renderPreview(sfx2::StyleManager* pStyleManager, OutputDevice& aOutputDevic
 
     if (pStyleSheet)
     {
-        sfx2::StylePreviewRenderer* pStylePreviewRenderer;
-        pStylePreviewRenderer = pStyleManager->CreateStylePreviewRenderer(aOutputDevice, pStyleSheet, nHeight);
+        std::unique_ptr<sfx2::StylePreviewRenderer> pStylePreviewRenderer
+            = pStyleManager->CreateStylePreviewRenderer(aOutputDevice, pStyleSheet, nHeight);
         pStylePreviewRenderer->recalculate();
         pStylePreviewRenderer->render(aRect, sfx2::StylePreviewRenderer::RenderAlign::TOP);
     }
commit 9d5b5eb966b5144ea7ccc17427ed96e89b7a40d7
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Fri Apr 13 14:18:01 2018 +0200

    make AnyWidget::Clone return std::unique_ptr
    
    Change-Id: I8c3af49ae0b3479a59e0dc61ecafddf7a83ba75a
    Reviewed-on: https://gerrit.libreoffice.org/52841
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/include/vcl/pdfwriter.hxx b/include/vcl/pdfwriter.hxx
index 1e38a9f67cb8..0f579d52b1b7 100644
--- a/include/vcl/pdfwriter.hxx
+++ b/include/vcl/pdfwriter.hxx
@@ -268,7 +268,7 @@ public:
 
         WidgetType getType() const { return Type; }
 
-        virtual AnyWidget* Clone() const = 0;
+        virtual std::unique_ptr<AnyWidget> Clone() const = 0;
 
     protected:
         // note that this equals the default compiler-generated copy-ctor, but we want to have it
@@ -327,9 +327,9 @@ public:
                   Dest( -1 ), Submit( false ), SubmitGet( false )
         {}
 
-        virtual AnyWidget* Clone() const override
+        virtual std::unique_ptr<AnyWidget> Clone() const override
         {
-            return new PushButtonWidget( *this );
+            return std::unique_ptr<AnyWidget>(new PushButtonWidget( *this ));
         }
     };
 
@@ -342,9 +342,9 @@ public:
                   Checked( false )
         {}
 
-        virtual AnyWidget* Clone() const override
+        virtual std::unique_ptr<AnyWidget> Clone() const override
         {
-            return new CheckBoxWidget( *this );
+            return std::unique_ptr<AnyWidget>(new CheckBoxWidget( *this ));
         }
     };
 
@@ -360,9 +360,9 @@ public:
                   RadioGroup( 0 )
         {}
 
-        virtual AnyWidget* Clone() const override
+        virtual std::unique_ptr<AnyWidget> Clone() const override
         {
-            return new RadioButtonWidget( *this );
+            return std::unique_ptr<AnyWidget>(new RadioButtonWidget( *this ));
         }
         // radio buttons having the same RadioGroup id comprise one
         // logical radio button group, that is at most one of the RadioButtons
@@ -389,9 +389,9 @@ public:
                   MaxLen( 0 )
         {}
 
-        virtual AnyWidget* Clone() const override
+        virtual std::unique_ptr<AnyWidget> Clone() const override
         {
-            return new EditWidget( *this );
+            return std::unique_ptr<AnyWidget>(new EditWidget( *this ));
         }
     };
 
@@ -411,9 +411,9 @@ public:
                   MultiSelect( false )
         {}
 
-        virtual AnyWidget* Clone() const override
+        virtual std::unique_ptr<AnyWidget> Clone() const override
         {
-            return new ListBoxWidget( *this );
+            return std::unique_ptr<AnyWidget>(new ListBoxWidget( *this ));
         }
     };
 
@@ -427,9 +427,9 @@ public:
                 : AnyWidget( vcl::PDFWriter::ComboBox )
         {}
 
-        virtual AnyWidget* Clone() const override
+        virtual std::unique_ptr<AnyWidget> Clone() const override
         {
-            return new ComboBoxWidget( *this );
+            return std::unique_ptr<AnyWidget>(new ComboBoxWidget( *this ));
         }
     };
 
@@ -439,9 +439,9 @@ public:
                 : AnyWidget( vcl::PDFWriter::Signature )
         {}
 
-        virtual AnyWidget* Clone() const override
+        virtual std::unique_ptr<AnyWidget> Clone() const override
         {
-            return new SignatureWidget( *this );
+            return std::unique_ptr<AnyWidget>(new SignatureWidget( *this ));
         }
     };
 


More information about the Libreoffice-commits mailing list