[haiku-commits] haiku: hrev51051 - src/preferences/media

  • From: humdingerb@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Wed, 29 Mar 2017 16:32:06 +0200 (CEST)

hrev51051 adds 1 changeset to branch 'master'
old head: deb50a898c23bb62d65aee31d5ae90d5443dbc12
new head: e633e9ef5a1be90faacd61570656a5b938067166
overview: 
http://cgit.haiku-os.org/haiku/log/?qt=range&q=e633e9ef5a1b+%5Edeb50a898c23

----------------------------------------------------------------------------

e633e9ef5a1b: 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.

                                        [ Humdinger <humdingerb@xxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev51051
Commit:      e633e9ef5a1be90faacd61570656a5b938067166
URL:         http://cgit.haiku-os.org/haiku/commit/?id=e633e9ef5a1b
Author:      Humdinger <humdingerb@xxxxxxxxx>
Date:        Tue Mar 28 18:27:56 2017 UTC

Ticket:      https://dev.haiku-os.org/ticket/13402

----------------------------------------------------------------------------

2 files changed, 11 insertions(+), 10 deletions(-)
src/preferences/media/MidiSettingsView.cpp | 14 +++++++-------
src/preferences/media/MidiSettingsView.h   |  7 ++++---

----------------------------------------------------------------------------

diff --git a/src/preferences/media/MidiSettingsView.cpp 
b/src/preferences/media/MidiSettingsView.cpp
index f5720e8..c1a3209 100644
--- a/src/preferences/media/MidiSettingsView.cpp
+++ b/src/preferences/media/MidiSettingsView.cpp
@@ -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;
                }
diff --git a/src/preferences/media/MidiSettingsView.h 
b/src/preferences/media/MidiSettingsView.h
index 2093b2d..b6b581a 100644
--- a/src/preferences/media/MidiSettingsView.h
+++ b/src/preferences/media/MidiSettingsView.h
@@ -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;
 };
 


Other related posts:

  • » [haiku-commits] haiku: hrev51051 - src/preferences/media - humdingerb