Re: [Rhythmbox-devel] Segmentation fault during property read



Hi, thanks for hint about unrefing.  covers_count is set during
another iteration witch I did not post (I did not kow how to read
number of covers in source). The problem is, that if I want to get
another property everything is ok (for example
RHYTHMDB_PROP_MOUNTPOINT), getting location produces errors.

Jonathan, did you write visualization plugin? I hacked it to make my
coverflow working. Are there any other C plugins I could see to
realize how people cope with playlists, sources, RythmDB and etc.?

Thanks for help,. I'll start to use debugger.


On Mon, Mar 3, 2008 at 11:56 PM, Jonathan Matthew
<notverysmart gmail com> wrote:
> On Tue, Mar 4, 2008 at 7:16 AM, Bartosz Wiklak <bwiklak gmail com> wrote:
>  > Hi, I'm doing something like that:
>  >
>  >         RBSource *source;
>  >         RhythmDBQueryModel *model;
>  >         RhythmDBEntry *entry1;
>  >         GtkTreeIter iter;
>  >         gboolean valid;
>  >         gchar buff[1024];
>  >
>  >     if(plugin->shell==NULL) g_print("NIC\n");
>  >
>  >         g_object_get (plugin->shell, "selected-source", &source, NULL);
>  >     g_object_get (source, "query-model", &model, NULL);
>
>  You need to unref objects you get via g_object_set when you're done with them
>
>
>  >         allSongsList = (SongInfo*)g_malloc( covers_count*sizeof(SongInfo) );
>
>  What is covers_count, and where is it being set to a useful value?  It
>  looks like you're allocating a zero length array here, so it'll crash
>  the first time you try to write to it...
>
>
>  >
>  >         valid = gtk_tree_model_get_iter_first (model, &iter);
>  >         covers_count=0;
>  >         while (valid)
>  >         {
>  >                 gchar *str_album = NULL;
>  >                 gchar *str_artist = NULL;
>  >
>  >
>  >         gtk_tree_model_get (model, &iter,  0, &entry1,-1);
>  >         str_album = rhythmdb_entry_get_string(entry1,RHYTHMDB_PROP_ALBUM);
>  >                 str_artist = rhythmdb_entry_get_string(entry1,RHYTHMDB_PROP_ARTIST);
>  >
>  >         if(str_artist){
>  >
>  >
>  >
>  >                        allSongsList[covers_count].songPath =
>  >  rhythmdb_entry_get_string(entry1,RHYTHMDB_PROP_LOCATION);
>
>  .. which is here.
>
>
>  >
>  >
>  >                         allSongsList[covers_count].coverPath= (gchar*)g_malloc( strlen(buff)+1 );
>  >                         strcpy(allSongsList[covers_count].coverPath,buff);
>  >                         g_print(allSongsList[covers_count].songPath);
>  >
>  >
>  >                 }
>  >                 valid = gtk_tree_model_iter_next (model, &iter);
>  >                 covers_count++;
>  >         }
>  >
>  >  When I'm tying to get file location (RHYTHMDB_PROP_LOCATION) I'm
>  >  getting segmentation fault.
>  >  What is wrong?
>
>  I'd suggest that gdb makes a better debugger than this mailing list.
>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]