GNOME Bugzilla – Bug 469524
Rhythmbox segfaults because of a Python plugin
Last modified: 2007-09-28 10:49:50 UTC
Please describe the problem: I've been trying to write a simple Python plugin that would allow me to choose a random artist or album from my library. While prototyping it in Python console everything worked OK. After wrapping it as a Plugin it stopped. Running a random_artist() method spawns many warnings and criticals: (11:41:39) [0x6c9500] [Randomizer.random_artist] /home/doomhammer/.gnome2/rhythmbox/plugins/randomizer/randomizer.py:107: Enter random_artist (11:41:39) [0x6c9500] [Randomizer.random_artist] /home/doomhammer/.gnome2/rhythmbox/plugins/randomizer/randomizer.py:113: Alan Menken (11:41:39) [0x6c9500] [Randomizer.random_artist] /home/doomhammer/.gnome2/rhythmbox/plugins/randomizer/randomizer.py:117: And now set_selection() (rhythmbox:5934): GLib-GObject-WARNING **: invalid unclassed pointer in cast to `GtkObject' (rhythmbox:5934): GLib-GObject-WARNING **: invalid unclassed pointer in cast to `GtkObject' (rhythmbox:5934): GLib-GObject-WARNING **: invalid unclassed pointer in cast to `GtkObject' (rhythmbox:5934): GLib-GObject-WARNING **: invalid unclassed pointer in cast to `GtkObject' (rhythmbox:5934): GLib-GObject-WARNING **: invalid unclassed pointer in cast to `GtkObject' (rhythmbox:5934): GLib-GObject-WARNING **: instance with invalid (NULL) class pointer (rhythmbox:5934): GLib-GObject-CRITICAL **: g_signal_emit_valist: assertion `G_TYPE_CHECK_INSTANCE (instance)' failed (rhythmbox:5934): GLib-GObject-WARNING **: invalid unclassed pointer in cast to `GtkObject' (rhythmbox:5934): GLib-GObject-WARNING **: instance with invalid (NULL) class pointer (rhythmbox:5934): GLib-GObject-CRITICAL **: g_signal_handlers_destroy: assertion `G_TYPE_CHECK_INSTANCE (instance)' failed (rhythmbox:5934): GLib-GObject-WARNING **: instance with invalid (NULL) class pointer (rhythmbox:5934): GLib-GObject-CRITICAL **: g_signal_handlers_destroy: assertion `G_TYPE_CHECK_INSTANCE (instance)' failed (rhythmbox:5934): GLib-GObject-WARNING **: invalid uninstantiatable type `<invalid>' in cast to `GtkObject' (rhythmbox:5934): GLib-GObject-WARNING **: invalid uninstantiatable type `<invalid>' in cast to `GtkObject' (rhythmbox:5934): GLib-GObject-WARNING **: invalid uninstantiatable type `<invalid>' in cast to `GtkObject' (rhythmbox:5934): GLib-GObject-WARNING **: invalid uninstantiatable type `<invalid>' in cast to `GtkObject' (rhythmbox:5934): GLib-GObject-WARNING **: invalid uninstantiatable type `<invalid>' in cast to `GtkObject' (rhythmbox:5934): GLib-GObject-WARNING **: instance of invalid non-instantiatable type `<invalid>' (rhythmbox:5934): GLib-GObject-CRITICAL **: g_signal_emit_valist: assertion `G_TYPE_CHECK_INSTANCE (instance)' failed (rhythmbox:5934): GLib-GObject-WARNING **: invalid uninstantiatable type `<invalid>' in cast to `GtkObject' (rhythmbox:5934): GLib-GObject-WARNING **: instance of invalid non-instantiatable type `<invalid>' (rhythmbox:5934): GLib-GObject-CRITICAL **: g_signal_handlers_destroy: assertion `G_TYPE_CHECK_INSTANCE (instance)' failed (rhythmbox:5934): GLib-GObject-WARNING **: instance of invalid non-instantiatable type `<invalid>' (rhythmbox:5934): GLib-GObject-CRITICAL **: g_signal_handlers_destroy: assertion `G_TYPE_CHECK_INSTANCE (instance)' failed (rhythmbox:5934): GLib-GObject-WARNING **: invalid cast from `(null)' to `GtkObject' (rhythmbox:5934): GLib-GObject-WARNING **: invalid cast from `(null)' to `GtkObject' (rhythmbox:5934): GLib-GObject-WARNING **: invalid cast from `(null)' to `GtkObject' (rhythmbox:5934): GLib-GObject-WARNING **: invalid cast from `(null)' to `GtkObject' (rhythmbox:5934): GLib-GObject-WARNING **: invalid cast from `(null)' to `GtkObject' (rhythmbox:5934): GLib-GObject-WARNING **: /build/buildd/glib2.0-2.14.0/gobject/gsignal.c:2133: signal id `2' is invalid for instance `0xc56ce0' (rhythmbox:5934): GLib-GObject-WARNING **: invalid cast from `(null)' to `GtkObject' (rhythmbox:5934): Rhythmbox-CRITICAL **: rb_property_view_get_model: assertion `RB_IS_PROPERTY_VIEW (view)' failed (rhythmbox:5934): GLib-GObject-CRITICAL **: g_object_get: assertion `G_IS_OBJECT (object)' failed Segmentation fault (core dumped) Steps to reproduce: import rhythmdb, rb import gtk import random ui_str = """ <ui> <menubar name="MenuBar"> <menu name="ControlMenu" action="Control"> <menuitem name="RandomArtist" action="RandomArtist"/> <menuitem name="RandomAlbum" action="RandomAlbum"/> </menu> </menubar> </ui> """ class Randomizer(rb.Plugin): def __init__(self): rb.Plugin.__init__(self) def activate(self, shell): self.shell = shell self.artist_action = gtk.Action ('RandomArtist', _('Random Artist'), _(''), None) self.activate_id = self.artist_action.connect ('activate', self.random_artist, shell) self.album_action = gtk.Action ('RandomAlbum', _('Random Album'), _(''), None) self.activate_id = self.album_action.connect ('activate', self.random_album, shell) self.action_group = gtk.ActionGroup ('RandomizerPluginActions') self.action_group.add_action_with_accel (self.artist_action, "<control>T") self.action_group.add_action_with_accel (self.album_action, "<control>M") uim = shell.get_ui_manager () uim.insert_action_group (self.action_group, 0) self.ui_id = uim.add_ui_from_string (ui_str) uim.ensure_update () self.db = self.shell.props.db self.source = self.shell.props.library_source self.artists = list() self.albums = list() def deactivate(self, shell): del self.shell del self.db del self.source del self.artists del self.albums pass def random_artist(self, action, shell): print "Enter random_artist" for row in self.source.props.query_model: entry = row[0] self.artists.append(self.db.entry_get(entry, rhythmdb.PROP_ARTIST)) random_artist = random.choice(self.artists) print random_artist for view in self.source.get_property_views(): if view.props.prop == rhythmdb.PROP_ARTIST: # Lack of get_property_view() method print "And now set_selection()" view.set_selection([random_artist]) def random_album(self, action, shell): for row in self.source.props.query_model: entry = row[0] self.albums.append(self.db.entry_get(entry, rhythmdb.PROP_ALBUM)) random_album = random.choice(self.albums) for view in self.source.get_property_views(): if view.props.prop == rhythmdb.PROP_ALBUM: view.set_selection([random_album]) Actual results: Segmentation fault (core dumped) Expected results: Does this happen every time? Other information:
*** Bug 480298 has been marked as a duplicate of this bug. ***
Fixed in svn. Sorry for taking so long to look into this - turns out it was a fairly simple bug in the end.
Thanks a lot. Now it seems to work!