Plugged some holes in the last checkin

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3665 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
haydentech
2003-06-25 19:40:45 +00:00
parent 78563dcaec
commit 97c931825e
+30 -14
View File
@@ -347,22 +347,24 @@ void BStatusBar::SetBarHeight(float height)
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void BStatusBar::SetText (const char *string) void BStatusBar::SetText (const char *string)
{ {
// SetText frees the previous text and replaces it with a copy of the
// string that's passed. The string can be NULL.
if (fText) if (fText)
free(fText); free(fText);
if (string) fText = string ? strdup(string) : NULL;
fText = strdup(string);
Invalidate(); Invalidate();
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void BStatusBar::SetTrailingText(const char *string) void BStatusBar::SetTrailingText(const char *string)
{ {
// SetTrailingText frees the previous text and replaces it with a copy of the
// string that's passed. The string can be NULL.
if (fTrailingText) if (fTrailingText)
free(fTrailingText); free(fTrailingText);
if (string) fTrailingText = string ? strdup(string) : NULL;
fTrailingText = strdup(string);
Invalidate(); Invalidate();
} }
@@ -381,40 +383,54 @@ void BStatusBar::Update(float delta, const char *text, const char *trailingText)
if (fCurrent > fMax) if (fCurrent > fMax)
fCurrent = fMax; fCurrent = fMax;
if (fText) // Passing NULL for the text or trailingText argument retains the previous
free(fText); // text or trailing text string.
if (text) if (text)
fText = strdup(text); {
if (fText)
free(fText);
if (fTrailingText) fText = strdup(text);
free(fTrailingText); }
if (trailingText) if (trailingText)
{
if (fTrailingText)
free(fTrailingText);
fTrailingText = strdup(trailingText); fTrailingText = strdup(trailingText);
}
Invalidate(); Invalidate();
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void BStatusBar::Reset(const char *label, const char *trailingLabel) void BStatusBar::Reset(const char *label, const char *trailingLabel)
{ {
// Reset replaces the label and trailing label with copies of the
// strings passed as arguments. If either argument is NULL, the
// label or trailing label will be deleted and erased.
if (fLabel) if (fLabel)
free(fLabel); free(fLabel);
if (label) fLabel = label ? strdup(label) : NULL;
fLabel = strdup(label);
if (fTrailingLabel) if (fTrailingLabel)
free(fTrailingLabel); free(fTrailingLabel);
if (trailingLabel) fTrailingLabel = trailingLabel ? strdup(trailingLabel) : NULL;
fTrailingLabel = strdup(trailingLabel);
// Reset deletes and erases any text or trailing text
if (fText) if (fText)
{
free(fText); free(fText);
fText = NULL;
}
if (fTrailingText) if (fTrailingText)
{
free(fTrailingText); free(fTrailingText);
fTrailingText = NULL;
}
fCurrent = 0.0f; fCurrent = 0.0f;
fMax = 100.0f; fMax = 100.0f;