From 2291f7568496d86da08797847bafc48e9f9d97f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Fri, 18 Sep 2009 10:05:27 +0000 Subject: [PATCH] Fixed bugs in reference counting. The transform boxen need to acquire refs to the objects they transform. Fixes ticket #4536. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33170 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../icon-o-matic/transformable/TransformPointsBox.cpp | 3 +++ .../icon-o-matic/transformable/TransformShapesBox.cpp | 10 +++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/apps/icon-o-matic/transformable/TransformPointsBox.cpp b/src/apps/icon-o-matic/transformable/TransformPointsBox.cpp index 005a5cb9e6..9668c56bf2 100644 --- a/src/apps/icon-o-matic/transformable/TransformPointsBox.cpp +++ b/src/apps/icon-o-matic/transformable/TransformPointsBox.cpp @@ -31,6 +31,8 @@ TransformPointsBox::TransformPointsBox(CanvasView* view, fCount(count), fPoints(count > 0 ? new (nothrow) control_point[count] : NULL) { + fPath->Acquire(); + BRect bounds(0, 0, -1, -1); if (fPoints && fIndices) { @@ -68,6 +70,7 @@ TransformPointsBox::~TransformPointsBox() { delete[] fIndices; delete[] fPoints; + fPath->Release(); } // #pragma mark - diff --git a/src/apps/icon-o-matic/transformable/TransformShapesBox.cpp b/src/apps/icon-o-matic/transformable/TransformShapesBox.cpp index 5e8936f276..975a350694 100644 --- a/src/apps/icon-o-matic/transformable/TransformShapesBox.cpp +++ b/src/apps/icon-o-matic/transformable/TransformShapesBox.cpp @@ -31,7 +31,7 @@ TransformShapesBox::TransformShapesBox(CanvasView* view, fParentTransform() { - if (fShapes) { + if (fShapes != NULL) { // allocate storage for the current transformations // of each object fOriginals = new double[fCount * Transformable::matrix_size]; @@ -39,8 +39,10 @@ TransformShapesBox::TransformShapesBox(CanvasView* view, memcpy(fShapes, shapes, fCount * sizeof(Shape*)); for (int32 i = 0; i < fCount; i++) { - if (fShapes[i]) + if (fShapes[i]) { + fShapes[i]->Acquire(); fShapes[i]->AddObserver(this); + } } // trigger init @@ -55,8 +57,10 @@ TransformShapesBox::~TransformShapesBox() { if (fShapes) { for (int32 i = 0; i < fCount; i++) { - if (fShapes[i]) + if (fShapes[i]) { fShapes[i]->RemoveObserver(this); + fShapes[i]->Release(); + } } delete[] fShapes; }