Message screensaver: fix array delete[] problem on clang, style fixes
Change-Id: Ic0182e81e9267c69b92ed60a85026eb45cda3a2d Reviewed-on: https://review.haiku-os.org/c/haiku/+/2407 Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
@@ -90,7 +90,10 @@ class Message : public BScreenSaver
|
||||
status_t StartSaver(BView *view, bool preview);
|
||||
|
||||
private:
|
||||
BObjectList<font_family> fFontFamilies;
|
||||
struct font_family_wrapper {
|
||||
font_family val;
|
||||
};
|
||||
BObjectList<font_family_wrapper> fFontFamilies;
|
||||
float fScaleFactor;
|
||||
bool fPreview;
|
||||
};
|
||||
@@ -112,7 +115,7 @@ Message::~Message()
|
||||
{
|
||||
for (int32 i = 0; i < fFontFamilies.CountItems(); i++) {
|
||||
if (fFontFamilies.ItemAt(i))
|
||||
delete[] fFontFamilies.ItemAt(i);
|
||||
delete fFontFamilies.ItemAt(i);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,14 +139,14 @@ Message::StartSaver(BView *view, bool preview)
|
||||
// Get font families
|
||||
int numFamilies = count_font_families();
|
||||
for (int32 i = 0; i < numFamilies; i++) {
|
||||
font_family* family = new font_family[1];
|
||||
font_family_wrapper* family = new font_family_wrapper;
|
||||
uint32 flags;
|
||||
if (get_font_family(i, family, &flags) == B_OK
|
||||
if (get_font_family(i, &(family->val), &flags) == B_OK
|
||||
&& (flags & B_IS_FIXED) == 0) {
|
||||
// Do not add fixed fonts
|
||||
fFontFamilies.AddItem(family);
|
||||
} else
|
||||
delete[] family;
|
||||
delete family;
|
||||
}
|
||||
|
||||
// Seed the random number generator
|
||||
@@ -198,7 +201,7 @@ Message::Draw(BView *view, int32 frame)
|
||||
BFont font;
|
||||
offscreen.GetFont(&font);
|
||||
font.SetFace(B_BOLD_FACE);
|
||||
font.SetFamilyAndStyle(*(fFontFamilies.ItemAt(rand() % fFontFamilies.CountItems())), NULL);
|
||||
font.SetFamilyAndStyle(fFontFamilies.ItemAt(rand() % fFontFamilies.CountItems())->val, NULL);
|
||||
offscreen.SetFont(&font);
|
||||
|
||||
// Get the message
|
||||
|
||||
Reference in New Issue
Block a user