* 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:
@@ -205,9 +205,13 @@ BScrollBar::BScrollBar(BRect frame, const char* name, BView *target,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BScrollBar::BScrollBar(BMessage *data)
|
BScrollBar::BScrollBar(BMessage* data)
|
||||||
: BView(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)
|
if (data->FindFloat("_range", 0, &fMin) < B_OK)
|
||||||
fMin = 0.0;
|
fMin = 0.0;
|
||||||
if (data->FindFloat("_range", 1, &fMax) < B_OK)
|
if (data->FindFloat("_range", 1, &fMax) < B_OK)
|
||||||
@@ -231,14 +235,8 @@ BScrollBar::BScrollBar(BMessage *data)
|
|||||||
|
|
||||||
BScrollBar::~BScrollBar()
|
BScrollBar::~BScrollBar()
|
||||||
{
|
{
|
||||||
if (fTarget) {
|
SetTarget((BView*)NULL);
|
||||||
if (fOrientation == B_VERTICAL)
|
|
||||||
fTarget->fVerScroller = NULL;
|
|
||||||
else
|
|
||||||
fTarget->fHorScroller = NULL;
|
|
||||||
}
|
|
||||||
delete fPrivateData;
|
delete fPrivateData;
|
||||||
free(fTargetName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -488,8 +486,16 @@ BScrollBar::GetSteps(float* smallStep, float* largeStep) const
|
|||||||
|
|
||||||
|
|
||||||
void
|
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;
|
fTarget = target;
|
||||||
free(fTargetName);
|
free(fTargetName);
|
||||||
|
|
||||||
@@ -508,6 +514,9 @@ BScrollBar::SetTarget(BView *target)
|
|||||||
void
|
void
|
||||||
BScrollBar::SetTarget(const char* targetName)
|
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)
|
if (!targetName)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user