Kaydet (Commit) 082b5628 authored tarafından Caolán McNamara's avatar Caolán McNamara

coverity#1439599 Uninitialized pointer field

Change-Id: I083e9e01e26f294064104a4682c50a9bfc7fa09c
Reviewed-on: https://gerrit.libreoffice.org/60848
Tested-by: Jenkins
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst a9ec212c
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include <vcl/customweld.hxx> #include <vcl/customweld.hxx>
#include <svx/svxdllapi.h> #include <svx/svxdllapi.h>
#include <svx/svdobj.hxx>
#include <memory> #include <memory>
class SfxItemSet; class SfxItemSet;
...@@ -33,7 +34,7 @@ class SVX_DLLPUBLIC SvxXMeasurePreview : public weld::CustomWidgetController ...@@ -33,7 +34,7 @@ class SVX_DLLPUBLIC SvxXMeasurePreview : public weld::CustomWidgetController
private: private:
MapMode m_aMapMode; MapMode m_aMapMode;
SdrMeasureObj* pMeasureObj; std::unique_ptr<SdrMeasureObj, SdrObjectFreeOp> pMeasureObj;
std::unique_ptr<SdrModel> pModel; std::unique_ptr<SdrModel> pModel;
void ResizeImpl(const Size& rSize); void ResizeImpl(const Size& rSize);
......
...@@ -41,7 +41,7 @@ void SvxXMeasurePreview::SetDrawingArea(weld::DrawingArea* pDrawingArea) ...@@ -41,7 +41,7 @@ void SvxXMeasurePreview::SetDrawingArea(weld::DrawingArea* pDrawingArea)
pDrawingArea->set_size_request(aSize.Width(), aSize.Height()); pDrawingArea->set_size_request(aSize.Width(), aSize.Height());
pModel.reset(new SdrModel(nullptr, nullptr, true)); pModel.reset(new SdrModel(nullptr, nullptr, true));
pMeasureObj = new SdrMeasureObj(*pModel, Point(), Point()); pMeasureObj.reset(new SdrMeasureObj(*pModel, Point(), Point()));
ResizeImpl(aSize); ResizeImpl(aSize);
Invalidate(); Invalidate();
...@@ -72,17 +72,6 @@ void SvxXMeasurePreview::Resize() ...@@ -72,17 +72,6 @@ void SvxXMeasurePreview::Resize()
SvxXMeasurePreview::~SvxXMeasurePreview() SvxXMeasurePreview::~SvxXMeasurePreview()
{ {
// No one is deleting the MeasureObj? This is not only an error but also
// a memory leak (!). Main problem is that this object is still listening to
// a StyleSheet of the model which was set. Thus, if You want to keep the object,
// set the model to 0L, if object is not needed (seems to be the case here),
// delete it.
// always use SdrObject::Free(...) for SdrObjects (!)
SdrObject* pTemp(pMeasureObj);
SdrObject::Free(pTemp);
pModel.reset();
} }
void SvxXMeasurePreview::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) void SvxXMeasurePreview::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment