patch for segmentation fault

Ralf Engels <[email protected]>
Newsgroups gmane.comp.audio.zinf.devel
Message-ID <[email protected]>
Hi,
again I had a segmentation fault.
This time starting zinf in windowmaker.

Please see the attached patch.
statusBar was not initialized to NULL

--- gtkmusicbrowser.cpp.old	2003-07-26 18:29:36.000000000 +0200
+++ gtkmusicbrowser.cpp	2003-07-26 18:54:17.000000000 +0200
@@ -1297,43 +1297,115 @@
  GTKMusicBrowser::GTKMusicBrowser(FAContext *context, MusicBrowserUI 
*masterUI,
                                   string playlistURL, bool cdCreationMode)
  {
-    m_context = context;
-    m_initialized = false;
-    isVisible = false;
+  /* --- initialize every object variable in order of gtkmusicbrowser.h
+     so many object variables are a sign of bad OO (Ralf) */
+
      m_lastindex = 0;
+    /* m_playlistColumnSort = ?? */
+    m_playlistLastSort = 0;
      m_currentListName = "";
-    m_state = kStateCollapsed;
-    statusContext = 0;
-    playlistList = NULL;
-    m_musicCatalog = NULL;
-    lastPanedPosition = -1;
-    lastPanedHandle = -1;
+    mbSelections = new vector<TreeData *>;
+    musicBrowserTree = NULL;
      pauseState = 0;
      stopState = 1;
-    musicBrowserTree = NULL;
-    m_playingindex = kInvalidIndex;
-    iSetRepeatMode = false;
-    iSetShuffleMode = false;
+    CDTracks = new vector<PlaylistItem *>;
+
+    m_context = context;
+
+    parentUI = masterUI;
+    stream_timer_started = false;
+    stream_timer = NULL;
      CD_DiscID = 0;
      CD_numtracks = 0;
      scheduleCDredraw = false;
-    CDTracks = new vector<PlaylistItem *>;
-    m_bIgnoringMusicCatalogMessages = false;
      m_bCDMode = cdCreationMode;
-    m_mbState =    kTreeMyMusic;
-    stream_timer_started = false;
-    stream_timer = NULL;
+    isVisible = false;
+    m_propManager = NULL;
+    m_initialized = false;
+    /* master (initialized below) */
+    iSetRepeatMode = false;
+    m_playingindex = kInvalidIndex;
+    m_bIgnoringMusicCatalogMessages = false;
+    /* m_plm (initialized below) */
+    m_musicCatalog = NULL;
+    m_state = kStateCollapsed;
+    m_clickState = kContextNone;
+    m_mbState = kTreeMyMusic;
+    lastPanedPosition = -1;
+    lastPanedHandle = -1;
+
+    musicBrowser = NULL;
+    masterBox = NULL;
+    masterBrowserBox = NULL;
+    masterPlaylistBox = NULL;
+    musicBrowserWindow = NULL;
+    playlistList = NULL;
+    playlistOMenu = NULL;
+    playlistMenu = NULL;
+    addTrack = NULL;
+    addFile = NULL;
+    toolRemove = NULL;
+    toolUp = NULL;
+    toolDown = NULL;
+    toolbar = NULL;
+    playlistLabel = NULL;
+    menuFactory = NULL;
+    playlistPopup = NULL;
+    playlist2Popup = NULL;
+    genstreamPopup = NULL;
+    streamPopup = NULL;
+    favPopup = NULL;
+    cdPopup = NULL;
+    trackPopup = NULL;
+    artistalbumPopup = NULL;
+    playlistCatPopup = NULL;
+    otherPopup = NULL;
+
+    mainTree = NULL;
+    allTree = NULL;
+    uncatTree = NULL;
+    playlistTree = NULL;
+    CDTree = NULL;
+    streamTree = NULL;
+    favoritesTree = NULL;
+    streamSpace = NULL;
+
+    streamExpanded = false;
      m_sigsExist = false;
      m_sigsStart = true;
-    playlistColsChanged = true;
+
+    normStyle = NULL;
+    boldStyle = NULL;
+    redStyle = NULL;
+    greenStyle = NULL;
+
+    album_pmap = NULL;
+    album_mask = NULL;
+    artist_pmap = NULL;
+    artist_mask = NULL;
+    playlist_pmap = NULL;
+    playlist_mask = NULL;
+    track_pmap = NULL;
+    track_mask = NULL;
+    stream_pmap = NULL;
+    stream_mask = NULL;
+
+    statusBar = NULL;
+    statusContext = 0;
+
+    artistSubTree = NULL;
+    playlistSubTree = NULL;
+
      uint32_t pos = 0;
      for (int i = 0; i < 8; i++)
          playlistCols[i] = kEmptyColumn;
      playlistCols[0] = kPositionColumn;

-    mbSelections = new vector<TreeData *>;
+    playlistColsChanged = true;
+
+
+    iSetShuffleMode = false;

-    parentUI = masterUI;

      if (playlistURL.find("currentlist.m3u") <= playlistURL.length()) {
          m_plm = context->plm;
gtkmusicbrowser.patch (text/plain, 3.7 KB)
--- gtkmusicbrowser.cpp.old	2003-07-26 18:29:36.000000000 +0200
+++ gtkmusicbrowser.cpp	2003-07-26 18:54:17.000000000 +0200
@@ -1297,43 +1297,115 @@
 GTKMusicBrowser::GTKMusicBrowser(FAContext *context, MusicBrowserUI *masterUI,
                                  string playlistURL, bool cdCreationMode)
 {
-    m_context = context;
-    m_initialized = false;
-    isVisible = false;
+  /* --- initialize every object variable in order of gtkmusicbrowser.h 
+     so many object variables are a sign of bad OO (Ralf) */
+
     m_lastindex = 0;
+    /* m_playlistColumnSort = ?? */
+    m_playlistLastSort = 0;
     m_currentListName = "";
-    m_state = kStateCollapsed;
-    statusContext = 0;
-    playlistList = NULL;
-    m_musicCatalog = NULL;
-    lastPanedPosition = -1;
-    lastPanedHandle = -1;
+    mbSelections = new vector<TreeData *>;
+    musicBrowserTree = NULL;
     pauseState = 0;
     stopState = 1;
-    musicBrowserTree = NULL;
-    m_playingindex = kInvalidIndex;
-    iSetRepeatMode = false;
-    iSetShuffleMode = false;
+    CDTracks = new vector<PlaylistItem *>;
+
+    m_context = context;
+
+    parentUI = masterUI;
+    stream_timer_started = false;
+    stream_timer = NULL;
     CD_DiscID = 0;
     CD_numtracks = 0;
     scheduleCDredraw = false;
-    CDTracks = new vector<PlaylistItem *>;
-    m_bIgnoringMusicCatalogMessages = false;
     m_bCDMode = cdCreationMode;
-    m_mbState =    kTreeMyMusic;
-    stream_timer_started = false;
-    stream_timer = NULL;
+    isVisible = false;
+    m_propManager = NULL;
+    m_initialized = false;
+    /* master (initialized below) */
+    iSetRepeatMode = false;
+    m_playingindex = kInvalidIndex;
+    m_bIgnoringMusicCatalogMessages = false;
+    /* m_plm (initialized below) */
+    m_musicCatalog = NULL;
+    m_state = kStateCollapsed;
+    m_clickState = kContextNone;
+    m_mbState = kTreeMyMusic;
+    lastPanedPosition = -1;
+    lastPanedHandle = -1;
+
+    musicBrowser = NULL;
+    masterBox = NULL;
+    masterBrowserBox = NULL;
+    masterPlaylistBox = NULL;
+    musicBrowserWindow = NULL;
+    playlistList = NULL;
+    playlistOMenu = NULL;
+    playlistMenu = NULL;
+    addTrack = NULL;
+    addFile = NULL;
+    toolRemove = NULL;
+    toolUp = NULL;
+    toolDown = NULL;
+    toolbar = NULL;
+    playlistLabel = NULL;
+    menuFactory = NULL;
+    playlistPopup = NULL;
+    playlist2Popup = NULL;
+    genstreamPopup = NULL;
+    streamPopup = NULL;
+    favPopup = NULL;
+    cdPopup = NULL;
+    trackPopup = NULL;
+    artistalbumPopup = NULL;
+    playlistCatPopup = NULL;
+    otherPopup = NULL;
+
+    mainTree = NULL;
+    allTree = NULL;
+    uncatTree = NULL;
+    playlistTree = NULL;
+    CDTree = NULL;
+    streamTree = NULL;
+    favoritesTree = NULL;
+    streamSpace = NULL;
+
+    streamExpanded = false;
     m_sigsExist = false;
     m_sigsStart = true;
-    playlistColsChanged = true;
+
+    normStyle = NULL;
+    boldStyle = NULL;
+    redStyle = NULL;
+    greenStyle = NULL;
+
+    album_pmap = NULL;
+    album_mask = NULL;
+    artist_pmap = NULL;
+    artist_mask = NULL;
+    playlist_pmap = NULL;
+    playlist_mask = NULL;
+    track_pmap = NULL;
+    track_mask = NULL;
+    stream_pmap = NULL;
+    stream_mask = NULL;
+
+    statusBar = NULL;
+    statusContext = 0;
+    
+    artistSubTree = NULL;
+    playlistSubTree = NULL;
+
     uint32_t pos = 0; 
     for (int i = 0; i < 8; i++)
         playlistCols[i] = kEmptyColumn;
     playlistCols[0] = kPositionColumn;
 
-    mbSelections = new vector<TreeData *>;
+    playlistColsChanged = true;
+
+
+    iSetShuffleMode = false;
 
-    parentUI = masterUI;
  
     if (playlistURL.find("currentlist.m3u") <= playlistURL.length()) {
         m_plm = context->plm;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.