From 188ba2f72a6dc6369d5cfe07374ffed12aece636 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Sat, 21 Jun 2008 08:39:14 +0000 Subject: [PATCH] * SetTarget((BView*)NULL) needs to unset the previous target's pointer to the scrollbar. * Added notes about BeOS behavior to SetTarget(const char*). * Reuse SetTarget(NULL) in the destructor. * Initialize fTarget and fTargetName in the archive constructor. * Added TODO about possibly restoring the target in the archive constructor. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26057 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/ScrollBar.cpp | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/src/kits/interface/ScrollBar.cpp b/src/kits/interface/ScrollBar.cpp index 69d86d6604..c356d64cf0 100644 --- a/src/kits/interface/ScrollBar.cpp +++ b/src/kits/interface/ScrollBar.cpp @@ -205,9 +205,13 @@ BScrollBar::BScrollBar(BRect frame, const char* name, BView *target, } -BScrollBar::BScrollBar(BMessage *data) - : BView(data) +BScrollBar::BScrollBar(BMessage* data) + : BView(data), + fTarget(NULL), + fTargetName(NULL) { + // TODO: Does the BeOS implementation try to find the target + // by name again? Does it archive the name at all? if (data->FindFloat("_range", 0, &fMin) < B_OK) fMin = 0.0; if (data->FindFloat("_range", 1, &fMax) < B_OK) @@ -231,14 +235,8 @@ BScrollBar::BScrollBar(BMessage *data) BScrollBar::~BScrollBar() { - if (fTarget) { - if (fOrientation == B_VERTICAL) - fTarget->fVerScroller = NULL; - else - fTarget->fHorScroller = NULL; - } + SetTarget((BView*)NULL); delete fPrivateData; - free(fTargetName); } @@ -488,8 +486,16 @@ BScrollBar::GetSteps(float* smallStep, float* largeStep) const void -BScrollBar::SetTarget(BView *target) +BScrollBar::SetTarget(BView* target) { + if (fTarget) { + // unset the previous target's scrollbar pointer + if (fOrientation == B_VERTICAL) + fTarget->fVerScroller = NULL; + else + fTarget->fHorScroller = NULL; + } + fTarget = target; free(fTargetName); @@ -508,6 +514,9 @@ BScrollBar::SetTarget(BView *target) void BScrollBar::SetTarget(const char* targetName) { + // NOTE 1: BeOS implementation crashes for targetName == NULL + // NOTE 2: BeOS implementation also does not modify the target + // if it can't be found if (!targetName) return;