Fix crash with missing midi_settings
fActiveSoundFont wasn't initialized when there's no midi_settings file. Don't allocate it on the heap, the object get implicitely initialized to an emtpy string. Tiny style fix. Thanks to AnEvilYak for his consultation. Fixes #13402.
This commit is contained in:
parent
deb50a898c
commit
e633e9ef5a
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2016, Haiku, Inc. All rights reserved.
|
||||
* Copyright 2014-2017, Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
@ -113,7 +113,7 @@ MidiSettingsView::MessageReceived(BMessage* message)
|
||||
} else if (olditem != NULL) {
|
||||
for (int32 i = 0; i < fListView->CountItems(); i++) {
|
||||
BStringItem* item = (BStringItem*)fListView->ItemAt(i);
|
||||
if (!strcmp(item->Text(), olditem->Text())) {
|
||||
if (strcmp(item->Text(), olditem->Text()) == 0) {
|
||||
fListView->Select(i);
|
||||
break;
|
||||
}
|
||||
@ -200,17 +200,17 @@ MidiSettingsView::_LoadSettings()
|
||||
{
|
||||
struct BPrivate::midi_settings settings;
|
||||
if (BPrivate::read_midi_settings(&settings) == B_OK)
|
||||
fActiveSoundFont = new BString(settings.soundfont_file);
|
||||
fActiveSoundFont.SetTo(settings.soundfont_file);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MidiSettingsView::_SaveSettings()
|
||||
{
|
||||
fActiveSoundFont = new BString(_SelectedSoundFont());
|
||||
if (fActiveSoundFont->Length() > 0) {
|
||||
fActiveSoundFont = _SelectedSoundFont();
|
||||
if (fActiveSoundFont.Length() > 0) {
|
||||
struct BPrivate::midi_settings settings;
|
||||
strlcpy(settings.soundfont_file, fActiveSoundFont->String(),
|
||||
strlcpy(settings.soundfont_file, fActiveSoundFont.String(),
|
||||
sizeof(settings.soundfont_file));
|
||||
BPrivate::write_midi_settings(settings);
|
||||
}
|
||||
@ -228,7 +228,7 @@ MidiSettingsView::_SelectActiveSoundFont()
|
||||
}
|
||||
for (int32 i = 0; i < fListView->CountItems(); i++) {
|
||||
BStringItem* item = (BStringItem*)fListView->ItemAt(i);
|
||||
if (!strcmp(item->Text(), fActiveSoundFont->String())) {
|
||||
if (strcmp(item->Text(), fActiveSoundFont.String()) == 0) {
|
||||
fListView->Select(i);
|
||||
break;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2016, Haiku, Inc. All rights reserved.
|
||||
* Copyright 2014-2017, Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
@ -7,11 +7,12 @@
|
||||
#define MIDIVIEW_H_
|
||||
|
||||
|
||||
#include <String.h>
|
||||
|
||||
#include "MediaViews.h"
|
||||
|
||||
class BButton;
|
||||
class BListView;
|
||||
class BString;
|
||||
class BStringView;
|
||||
|
||||
class MidiSettingsView : public SettingsView {
|
||||
@ -32,7 +33,7 @@ private:
|
||||
void _UpdateSoundFontStatus();
|
||||
|
||||
BListView* fListView;
|
||||
BString* fActiveSoundFont;
|
||||
BString fActiveSoundFont;
|
||||
BStringView* fSoundFontStatus;
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user