[rhythmbox] handle rb_source_get_entry_view returning NULL (bug #607073)
- From: Jonathan Matthew <jmatthew src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rhythmbox] handle rb_source_get_entry_view returning NULL (bug #607073)
- Date: Sat, 13 Mar 2010 14:18:08 +0000 (UTC)
commit e60fde964b18b1c32dc22137557290bc83bc32c9
Author: Jonathan Matthew <jonathan d14n org>
Date: Sat Mar 13 20:54:20 2010 +1000
handle rb_source_get_entry_view returning NULL (bug #607073)
Sources aren't actually required to have an entry view, so
rb_source_get_entry_view can return NULL, and code that doesn't know
exactly what type of source it's dealing with needs to handle that.
shell/rb-shell-clipboard.c | 8 ++++++--
shell/rb-shell.c | 17 +++++++++++------
sources/rb-source.c | 28 +++++++++++++++++++++++-----
widgets/rb-song-info.c | 6 +++++-
4 files changed, 45 insertions(+), 14 deletions(-)
---
diff --git a/shell/rb-shell-clipboard.c b/shell/rb-shell-clipboard.c
index 304516e..7f0bab5 100644
--- a/shell/rb-shell-clipboard.c
+++ b/shell/rb-shell-clipboard.c
@@ -692,7 +692,9 @@ rb_shell_clipboard_cmd_select_all (GtkAction *action,
} else {
/* select all tracks in the entry view */
entryview = rb_source_get_entry_view (clipboard->priv->source);
- rb_entry_view_select_all (entryview);
+ if (entryview != NULL) {
+ rb_entry_view_select_all (entryview);
+ }
}
}
@@ -709,7 +711,9 @@ rb_shell_clipboard_cmd_select_none (GtkAction *action,
gtk_editable_select_region (GTK_EDITABLE (widget), -1, -1);
} else {
entryview = rb_source_get_entry_view (clipboard->priv->source);
- rb_entry_view_select_none (entryview);
+ if (entryview != NULL) {
+ rb_entry_view_select_none (entryview);
+ }
}
}
diff --git a/shell/rb-shell.c b/shell/rb-shell.c
index 37bc2e0..f7d4c49 100644
--- a/shell/rb-shell.c
+++ b/shell/rb-shell.c
@@ -1414,7 +1414,9 @@ rb_shell_constructed (GObject *object)
RBEntryView *view;
view = rb_source_get_entry_view (RB_SOURCE (shell->priv->library_source));
- gtk_widget_grab_focus (GTK_WIDGET (view));
+ if (view != NULL) {
+ gtk_widget_grab_focus (GTK_WIDGET (view));
+ }
}
rb_profile_end ("constructing shell");
@@ -1881,9 +1883,10 @@ rb_shell_playing_from_queue_cb (RBShellPlayer *player,
RBEntryView *songs;
songs = rb_source_get_entry_view (source);
-
- state = from_queue ? RB_ENTRY_VIEW_PLAYING : RB_ENTRY_VIEW_NOT_PLAYING;
- rb_entry_view_set_state (songs, state);
+ if (songs != NULL) {
+ state = from_queue ? RB_ENTRY_VIEW_PLAYING : RB_ENTRY_VIEW_NOT_PLAYING;
+ rb_entry_view_set_state (songs, state);
+ }
}
rhythmdb_entry_unref (entry);
@@ -2721,8 +2724,10 @@ rb_shell_jump_to_entry_with_source (RBShell *shell,
songs = rb_source_get_entry_view (source);
rb_shell_select_source (shell, source);
- rb_entry_view_scroll_to_entry (songs, entry);
- rb_entry_view_select_entry (songs, entry);
+ if (songs != NULL) {
+ rb_entry_view_scroll_to_entry (songs, entry);
+ rb_entry_view_select_entry (songs, entry);
+ }
}
static void
diff --git a/sources/rb-source.c b/sources/rb-source.c
index 18ddac1..38890cd 100644
--- a/sources/rb-source.c
+++ b/sources/rb-source.c
@@ -1082,7 +1082,12 @@ rb_source_cut (RBSource *source)
static GList *
default_copy (RBSource *source)
{
- return rb_entry_view_get_selected_entries (rb_source_get_entry_view (source));
+ RBEntryView *entry_view;
+ entry_view = rb_source_get_entry_view (source);
+ if (entry_view == NULL)
+ return NULL;
+
+ return rb_entry_view_get_selected_entries (entry_view);
}
/**
@@ -1134,10 +1139,15 @@ static void
default_add_to_queue (RBSource *source,
RBSource *queue)
{
- RBEntryView *songs = rb_source_get_entry_view (source);
- GList *selection = rb_entry_view_get_selected_entries (songs);
+ RBEntryView *songs;
+ GList *selection;
GList *iter;
+ songs = rb_source_get_entry_view (source);
+ if (songs == NULL)
+ return;
+
+ selection = rb_entry_view_get_selected_entries (songs);
if (selection == NULL)
return;
@@ -1190,8 +1200,11 @@ default_move_to_trash (RBSource *source)
g_object_get (priv->shell, "db", &db, NULL);
+ sel = NULL;
entry_view = rb_source_get_entry_view (source);
- sel = rb_entry_view_get_selected_entries (entry_view);
+ if (entry_view != NULL) {
+ sel = rb_entry_view_get_selected_entries (entry_view);
+ }
for (tem = sel; tem != NULL; tem = tem->next) {
rhythmdb_entry_move_to_trash (db, (RhythmDBEntry *)tem->data);
@@ -1658,11 +1671,16 @@ GList *
rb_source_gather_selected_properties (RBSource *source,
RhythmDBPropType prop)
{
+ RBEntryView *entryview;
GList *selected, *tem;
GHashTable *selected_set;
+ entryview = rb_source_get_entry_view (source);
+ if (entryview == NULL)
+ return NULL;
+
selected_set = g_hash_table_new (g_str_hash, g_str_equal);
- selected = rb_entry_view_get_selected_entries (rb_source_get_entry_view (RB_SOURCE (source)));
+ selected = rb_entry_view_get_selected_entries (entryview);
for (tem = selected; tem; tem = tem->next) {
RhythmDBEntry *entry = tem->data;
diff --git a/widgets/rb-song-info.c b/widgets/rb-song-info.c
index e33bae3..475f9d1 100644
--- a/widgets/rb-song-info.c
+++ b/widgets/rb-song-info.c
@@ -764,8 +764,12 @@ rb_song_info_new (RBSource *source, RBEntryView *entry_view)
RBSongInfo *song_info;
g_return_val_if_fail (RB_IS_SOURCE (source), NULL);
- if (!entry_view)
+ if (entry_view == NULL) {
entry_view = rb_source_get_entry_view (source);
+ if (entry_view == NULL) {
+ return NULL;
+ }
+ }
if (rb_entry_view_have_selection (entry_view) == FALSE)
return NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]