diff --git a/src/apps/cortex/DormantNodeView/DormantNodeView.cpp b/src/apps/cortex/DormantNodeView/DormantNodeView.cpp index 2b5471dbea..5610a294b6 100644 --- a/src/apps/cortex/DormantNodeView/DormantNodeView.cpp +++ b/src/apps/cortex/DormantNodeView/DormantNodeView.cpp @@ -196,25 +196,29 @@ void DormantNodeView::MouseMoved( int32 index; if (!message && ((index = IndexOf(point)) >= 0)) { - DormantNodeListItem *item = dynamic_cast(ItemAt(index)); - DormantNodeListItem *last = dynamic_cast(m_lastItemUnder); - BRect r = item->getRealFrame(be_plain_font); - if (item && r.Contains(point)) { - if (item != last) { - if (last) - last->MouseOver(this, point, B_EXITED_VIEW); - item->MouseOver(this, point, B_ENTERED_VIEW); - m_lastItemUnder = item; - } - else { - item->MouseOver(this, point, B_INSIDE_VIEW); + DormantNodeListItem *item = + dynamic_cast(ItemAt(index)); + DormantNodeListItem *last = + dynamic_cast(m_lastItemUnder); + if (item != NULL) { + BRect r = item->getRealFrame(be_plain_font); + if (r.Contains(point)) { + if (item != last) { + if (last != NULL) + last->MouseOver(this, point, B_EXITED_VIEW); + item->MouseOver(this, point, B_ENTERED_VIEW); + m_lastItemUnder = item; + } + else { + item->MouseOver(this, point, B_INSIDE_VIEW); + } } } - else if (last) { + else if (last != NULL) { last->MouseOver(this, point, B_EXITED_VIEW); } } - + _inherited::MouseMoved(point, transit, message); } @@ -250,7 +254,7 @@ void DormantNodeView::_populateList() { int32 bufferSize = bufferInc; dormant_node_info *infoBuffer = new dormant_node_info[bufferSize]; int32 numNodes; - + // fill the buffer while (true) { numNodes = bufferSize; @@ -261,13 +265,13 @@ void DormantNodeView::_populateList() { if (numNodes < bufferSize) { break; } - + // reallocate buffer & try again delete [] infoBuffer; bufferSize += bufferInc; infoBuffer = new dormant_node_info[bufferSize]; } - + // populate the list for (int32 i = 0; i < numNodes; i++) { DormantNodeListItem *item = new DormantNodeListItem(infoBuffer[i]); @@ -298,7 +302,7 @@ void DormantNodeView::_updateList( int32 bufferSize = bufferInc; dormant_node_info *infoBuffer = new dormant_node_info[bufferSize]; int32 numNodes; - + // fill the buffer while (true) { numNodes = bufferSize; @@ -309,7 +313,7 @@ void DormantNodeView::_updateList( if (numNodes < bufferSize) { break; } - + // reallocate buffer & try again delete [] infoBuffer; bufferSize += bufferInc; diff --git a/src/apps/icon-o-matic/gui/SavePanel.cpp b/src/apps/icon-o-matic/gui/SavePanel.cpp index f8a83d6439..4fcf1a1ad8 100644 --- a/src/apps/icon-o-matic/gui/SavePanel.cpp +++ b/src/apps/icon-o-matic/gui/SavePanel.cpp @@ -73,16 +73,20 @@ SavePanel::SavePanel(const char* name, // add this instance as BHandler to the window's looper window->AddHandler(this); - + // find a couple of important views and mess with their layout BView* background = Window()->ChildAt(0); + if (background == NULL) { + printf("SavePanel::SavePanel() - couldn't find necessary controls.\n"); + return; + } BButton* cancel = dynamic_cast( background->FindView("cancel button")); BView* textview = background->FindView("text view"); BScrollBar* hscrollbar = dynamic_cast( background->FindView("HScrollBar")); - if (!background || !cancel || !textview || !hscrollbar) { + if (!cancel || !textview || !hscrollbar) { printf("SavePanel::SavePanel() - couldn't find necessary controls.\n"); return; } @@ -96,7 +100,7 @@ SavePanel::SavePanel(const char* name, rect.bottom = rect.top + fh.ascent + fh.descent + 5.0; fFormatMF = new BMenuField(rect, "format popup", B_TRANSLATE("Format"), - fFormatM, true, + fFormatM, true, B_FOLLOW_LEFT | B_FOLLOW_BOTTOM, B_WILL_DRAW | B_NAVIGABLE); fFormatMF->SetDivider(be_plain_font->StringWidth( @@ -129,7 +133,7 @@ SavePanel::SavePanel(const char* name, // Build the "Settings" button relative to the format menu rect = cancel->Frame(); rect.OffsetTo(fFormatMF->Frame().right + 5.0, rect.top); - fSettingsB = new BButton(rect, "settings", + fSettingsB = new BButton(rect, "settings", B_TRANSLATE("Settings" B_UTF8_ELLIPSIS), new BMessage(MSG_SETTINGS), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM, @@ -324,7 +328,7 @@ SavePanel::AdjustExtension() // // if (exporter) { // BString name(textview->Text()); -// +// // // adjust the name extension // const char* extension = exporter->Extension(); // if (strlen(extension) > 0) { @@ -335,7 +339,7 @@ SavePanel::AdjustExtension() // } // name << "." << extension; // } -// +// // SetSaveText(name.String()); // } // @@ -365,7 +369,7 @@ SavePanel::_ExportSettings() // BTranslatorRoster *roster = BTranslatorRoster::Default(); // BView *view; // BRect rect(0, 0, 239, 239); -// +// // // Build a window around this translator's configuration view // status_t err = roster->MakeConfigurationView(item->id, NULL, &view, &rect); // if (err < B_OK || view == NULL) { @@ -397,30 +401,30 @@ SavePanel::_BuildMenu() { fFormatM = new BPopUpMenu(B_TRANSLATE("Format")); - fNativeMI = new SaveItem("Icon-O-Matic", + fNativeMI = new SaveItem("Icon-O-Matic", new BMessage(MSG_FORMAT), EXPORT_MODE_MESSAGE); fFormatM->AddItem(fNativeMI); fNativeMI->SetEnabled(false); fFormatM->AddSeparatorItem(); - fHVIFMI = new SaveItem("HVIF", + fHVIFMI = new SaveItem("HVIF", new BMessage(MSG_FORMAT), EXPORT_MODE_FLAT_ICON); fFormatM->AddItem(fHVIFMI); - fRDefMI = new SaveItem("HVIF RDef", + fRDefMI = new SaveItem("HVIF RDef", new BMessage(MSG_FORMAT), EXPORT_MODE_ICON_RDEF); fFormatM->AddItem(fRDefMI); - fSourceMI = new SaveItem(B_TRANSLATE("HVIF Source Code"), + fSourceMI = new SaveItem(B_TRANSLATE("HVIF Source Code"), new BMessage(MSG_FORMAT), EXPORT_MODE_ICON_SOURCE); fFormatM->AddItem(fSourceMI); fFormatM->AddSeparatorItem(); - fSVGMI = new SaveItem("SVG", + fSVGMI = new SaveItem("SVG", new BMessage(MSG_FORMAT), EXPORT_MODE_SVG); - + fFormatM->AddItem(fSVGMI); fFormatM->AddSeparatorItem(); @@ -437,19 +441,19 @@ SavePanel::_BuildMenu() new BMessage(MSG_FORMAT), EXPORT_MODE_BITMAP_64); fFormatM->AddItem(fBitmap64MI); - fBitmapSetMI = new SaveItem(B_TRANSLATE("PNG Set"), + fBitmapSetMI = new SaveItem(B_TRANSLATE("PNG Set"), new BMessage(MSG_FORMAT), EXPORT_MODE_BITMAP_SET); fFormatM->AddItem(fBitmapSetMI); fFormatM->AddSeparatorItem(); - fIconAttrMI = new SaveItem(B_TRANSLATE("BEOS:ICON Attribute"), + fIconAttrMI = new SaveItem(B_TRANSLATE("BEOS:ICON Attribute"), new BMessage(MSG_FORMAT), EXPORT_MODE_ICON_ATTR); fFormatM->AddItem(fIconAttrMI); fIconMimeAttrMI = new SaveItem(B_TRANSLATE("META:ICON Attribute"), new BMessage(MSG_FORMAT), EXPORT_MODE_ICON_MIME_ATTR); - + fFormatM->AddItem(fIconMimeAttrMI); diff --git a/src/apps/mail/KUndoBuffer.cpp b/src/apps/mail/KUndoBuffer.cpp index 8b4533c1ae..84fa08ee87 100644 --- a/src/apps/mail/KUndoBuffer.cpp +++ b/src/apps/mail/KUndoBuffer.cpp @@ -14,10 +14,11 @@ KUndoItem::KUndoItem(const char* redo_text, int32 length, int32 offset, if (redo_text != NULL) { RedoText = (char*)malloc(length); - memcpy(RedoText, redo_text, length); - if (RedoText != NULL) + + if (RedoText != NULL) { + memcpy(RedoText, redo_text, length); fStatus = B_OK; - else + } else fStatus = B_ERROR; } } diff --git a/src/apps/soundrecorder/ScopeView.cpp b/src/apps/soundrecorder/ScopeView.cpp index 4a847e0635..0720624108 100644 --- a/src/apps/soundrecorder/ScopeView.cpp +++ b/src/apps/soundrecorder/ScopeView.cpp @@ -2,7 +2,7 @@ * Copyright 2005, Jérôme Duval. All rights reserved. * Distributed under the terms of the MIT License. * - * Inspired by SoundCapture from Be newsletter (Media Kit Basics: + * Inspired by SoundCapture from Be newsletter (Media Kit Basics: * Consumers and Producers) */ @@ -67,19 +67,19 @@ ScopeView::Draw(BRect updateRect) { BRect bounds = Bounds(); SetHighColor(0,0,0); - + if (!fIsRendering) DrawBitmapAsync(fBitmap, BPoint(0, 0)); - else + else FillRect(bounds); - + float x = 0; if (fTotalTime != 0) x += (fMainTime - fLeftTime) * bounds.right / (fRightTime - fLeftTime); SetHighColor(60,255,40); StrokeLine(BPoint(x, bounds.top), BPoint(x, bounds.bottom)); - + Sync(); } @@ -88,7 +88,7 @@ void ScopeView::Run() { fRenderSem = create_sem(0, "scope rendering"); - fThreadId = spawn_thread(&RenderLaunch, "Scope view", B_NORMAL_PRIORITY, + fThreadId = spawn_thread(&RenderLaunch, "Scope view", B_NORMAL_PRIORITY, this); if (fThreadId < 0) return; @@ -121,8 +121,8 @@ ScopeView::ComputeRendering() int64 framesCount = fMediaTrack->CountFrames() / SAMPLES_COUNT; if (framesCount <= 0) return; - T samples[fPlayFormat.u.raw_audio.buffer_size - / (fPlayFormat.u.raw_audio.format + T samples[fPlayFormat.u.raw_audio.buffer_size + / (fPlayFormat.u.raw_audio.format & media_raw_audio_format::B_AUDIO_SIZE_MASK)]; int64 frames = 0; U sum = 0; @@ -140,19 +140,19 @@ ScopeView::ComputeRendering() int64 framesIndex = 0; while (framesIndex < frames) { - for (; framesIndex < frames && sumCount < framesCount; + for (; framesIndex < frames && sumCount < framesCount; framesIndex++, sumCount++) { sum += samples[2 * framesIndex]; sum += samples[2 * framesIndex + 1]; } - + if (previewIndex >= SAMPLES_COUNT) break; - + if (sumCount >= framesCount) { - // TRACE("computing block %ld, sumCount %ld\n", previewIndex, + // TRACE("computing block %ld, sumCount %ld\n", previewIndex, // sumCount); - fPreview[previewIndex] = (int32)(sum + fPreview[previewIndex] = (int32)(sum / fPlayFormat.u.raw_audio.channel_count / framesCount); if (previewMax < fPreview[previewIndex]) previewMax = fPreview[previewIndex]; @@ -162,11 +162,11 @@ ScopeView::ComputeRendering() } } } - + if (previewMax <= 0) return; for (int i = 0; i < SAMPLES_COUNT; i++) - fPreview[i] = (int32)(fPreview[i] * 1.0 / previewMax + fPreview[i] = (int32)(fPreview[i] * 1.0 / previewMax * middle + middle); } @@ -176,7 +176,7 @@ ScopeView::RenderLoop() { while (acquire_sem(fRenderSem) == B_OK) { fIsRendering = true; - + switch (fPlayFormat.u.raw_audio.format) { case media_raw_audio_format::B_AUDIO_FLOAT: ComputeRendering(); @@ -194,28 +194,28 @@ ScopeView::RenderLoop() ComputeRendering(); break; } - + TRACE("finished computing, rendering\n"); - + /* rendering */ RenderBitmap(); - + TRACE("rendering done\n"); /* ask drawing */ - + fIsRendering = false; - + if (Window()->LockWithTimeout(5000) == B_OK) { Invalidate(); TRACE("invalidate done\n"); Window()->Unlock(); } - } + } } -void +void ScopeView::SetMainTime(bigtime_t timestamp) { fMainTime = timestamp; @@ -224,7 +224,7 @@ ScopeView::SetMainTime(bigtime_t timestamp) } -void +void ScopeView::SetTotalTime(bigtime_t timestamp, bool reset) { fTotalTime = timestamp; @@ -238,7 +238,7 @@ ScopeView::SetTotalTime(bigtime_t timestamp, bool reset) } -void +void ScopeView::SetLeftTime(bigtime_t timestamp) { fLeftTime = timestamp; @@ -247,7 +247,7 @@ ScopeView::SetLeftTime(bigtime_t timestamp) TRACE("invalidate done\n"); } -void +void ScopeView::SetRightTime(bigtime_t timestamp) { fRightTime = timestamp; @@ -299,10 +299,10 @@ ScopeView::MouseDown(BPoint position) drag.AddInt32("be:actions", B_COPY_TARGET); drag.AddString("be:clip_name", "Audio Clip"); drag.AddString("be:types", B_FILE_MIME_TYPE); - + uint8* data; size_t size; - + BMimeType wavType("audio/x-wav"); if (wavType.InitCheck() < B_OK || wavType.GetIcon(&data, &size) < B_OK) { @@ -329,20 +329,20 @@ ScopeView::MouseDown(BPoint position) void ScopeView::InitBitmap() { - if (fBitmapView) { + if (fBitmap != NULL && fBitmapView != NULL) { fBitmap->RemoveChild(fBitmapView); delete fBitmapView; } if (fBitmap) delete fBitmap; - + BRect rect = Bounds(); - + fBitmap = new BBitmap(rect, BScreen().ColorSpace(), true); memset(fBitmap->Bits(), 0, fBitmap->BitsLength()); - + rect.OffsetToSelf(B_ORIGIN); - fBitmapView = new BView(rect.OffsetToSelf(B_ORIGIN), "bitmapView", + fBitmapView = new BView(rect.OffsetToSelf(B_ORIGIN), "bitmapView", B_FOLLOW_LEFT|B_FOLLOW_TOP, B_WILL_DRAW); fBitmap->AddChild(fBitmapView); } @@ -353,26 +353,26 @@ ScopeView::RenderBitmap() { if (!fMediaTrack) return; - + /* rendering */ fBitmap->Lock(); memset(fBitmap->Bits(), 0, fBitmap->BitsLength()); float width = fBitmapView->Bounds().Width() + 1; - + fBitmapView->SetDrawingMode(B_OP_ADD); fBitmapView->SetHighColor(15,60,15); - int32 leftIndex = + int32 leftIndex = (fTotalTime != 0) ? fLeftTime * 20000 / fTotalTime : 0; - int32 rightIndex = + int32 rightIndex = (fTotalTime != 0) ? fRightTime * 20000 / fTotalTime : 20000; - + for (int32 i = leftIndex; iStrokeLine(point, point); } - + fBitmap->Unlock(); } diff --git a/src/bin/media_client/MediaPlay.cpp b/src/bin/media_client/MediaPlay.cpp index 6753f4684f..84234c6ce3 100644 --- a/src/bin/media_client/MediaPlay.cpp +++ b/src/bin/media_client/MediaPlay.cpp @@ -31,10 +31,10 @@ void play_buffer(void *cookie, void * buffer, size_t size, const media_raw_audio_format & format) { int64 frames = 0; - - // Use your feeling, Obi-Wan, and find him you will. + + // Use your feeling, Obi-Wan, and find him you will. playTrack->ReadFrames(buffer, &frames); - + if (frames <=0) { player->SetHasData(false); release_sem(finished); @@ -70,38 +70,39 @@ int media_play(const char* uri) delete playFile; return 2; } - + for (int i = 0; i < playFile->CountTracks(); i++) { BMediaTrack* track = playFile->TrackAt(i); - playFormat.type = B_MEDIA_RAW_AUDIO; - if ((track->DecodedFormat(&playFormat) == B_OK) + if (track != NULL) { + playFormat.type = B_MEDIA_RAW_AUDIO; + if ((track->DecodedFormat(&playFormat) == B_OK) && (playFormat.type == B_MEDIA_RAW_AUDIO)) { - playTrack = track; - break; - } - if (track) + playTrack = track; + break; + } playFile->ReleaseTrack(track); + } } - // Good relations with the Wookiees, I have. + // Good relations with the Wookiees, I have. signal(SIGINT, keyb_int); finished = create_sem(0, "finish wait"); - + printf("Playing file...\n"); - + // Execute Plan 66! player = new BSoundPlayer(&playFormat.u.raw_audio, "playfile", play_buffer); player->SetVolume(1.0f); - // Join me, Padmé and together we can rule this galaxy. + // Join me, Padmé and together we can rule this galaxy. player->SetHasData(true); player->Start(); acquire_sem(finished); if (interrupt == true) { - // Once more, the Sith will rule the galaxy. + // Once more, the Sith will rule the galaxy. printf("Interrupted\n"); player->Stop(); kill_thread(reader); diff --git a/src/preferences/screen/ScreenWindow.cpp b/src/preferences/screen/ScreenWindow.cpp index 496e6cad35..7043f1179e 100644 --- a/src/preferences/screen/ScreenWindow.cpp +++ b/src/preferences/screen/ScreenWindow.cpp @@ -738,7 +738,8 @@ ScreenWindow::_UpdateRefreshControl() if (item->Message()->FindFloat("refresh") == fSelected.refresh) { item->SetMarked(true); // "Other" items only contains a refresh rate when active - fOtherRefresh->SetLabel(B_TRANSLATE("Other" B_UTF8_ELLIPSIS)); + if (fOtherRefresh != NULL) + fOtherRefresh->SetLabel(B_TRANSLATE("Other" B_UTF8_ELLIPSIS)); return; } } diff --git a/src/preferences/screensaver/ScreenSaverWindow.cpp b/src/preferences/screensaver/ScreenSaverWindow.cpp index 49a8d5aca3..63bed647d7 100644 --- a/src/preferences/screensaver/ScreenSaverWindow.cpp +++ b/src/preferences/screensaver/ScreenSaverWindow.cpp @@ -1004,7 +1004,10 @@ TabView::MouseDown(BPoint where) BRect fadeTabFrame(TabFrame(0)); BTab* modulesTab = TabAt(1); BRect modulesTabFrame(TabFrame(1)); - ModulesView* modulesView = dynamic_cast(modulesTab->View()); + ModulesView* modulesView = NULL; + + if (modulesTab != NULL) + modulesView = dynamic_cast(modulesTab->View()); if (fadeTab != NULL && Selection() != 0 && fadeTabFrame.Contains(where) && modulesView != NULL) {