* 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
This commit is contained in:
Stephan Aßmus 2008-06-21 08:39:14 +00:00
parent 2760094c5c
commit 188ba2f72a

View File

@ -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;