[rygel] media-export: Fix crash on unknown QueryContainer
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel] media-export: Fix crash on unknown QueryContainer
- Date: Sun, 12 Aug 2012 17:54:17 +0000 (UTC)
commit 6755a280d0d537f517a53466c3bbbc3113a47943
Author: Jens Georg <mail jensge org>
Date: Sun Aug 12 17:52:49 2012 +0200
media-export: Fix crash on unknown QueryContainer
Previously get_by_id would return an empty id, leading in a null
container on which we tried to set the parent.
...rygel-media-export-query-container-factory.vala | 7 +++++--
.../rygel-media-export-root-container.vala | 4 +++-
2 files changed, 8 insertions(+), 3 deletions(-)
---
diff --git a/src/plugins/media-export/rygel-media-export-query-container-factory.vala b/src/plugins/media-export/rygel-media-export-query-container-factory.vala
index 3a6e632..cc1075c 100644
--- a/src/plugins/media-export/rygel-media-export-query-container-factory.vala
+++ b/src/plugins/media-export/rygel-media-export-query-container-factory.vala
@@ -85,12 +85,15 @@ internal class Rygel.MediaExport.QueryContainerFactory : Object {
* @param name An the title of the container. If not supplied, it will
* be derived from the plain-text description of the
* container
- * @return A new instance of QueryContainer
+ * @return A new instance of QueryContainer or null if id does not exist
*/
- public QueryContainer create_from_id (MediaCache cache,
+ public QueryContainer? create_from_id (MediaCache cache,
string id,
string name = "") {
var definition = this.get_virtual_container_definition (id);
+ if (definition == null) {
+ return null;
+ }
return this.create_from_description (cache, definition, name);
}
diff --git a/src/plugins/media-export/rygel-media-export-root-container.vala b/src/plugins/media-export/rygel-media-export-root-container.vala
index 3b15685..753e72f 100644
--- a/src/plugins/media-export/rygel-media-export-root-container.vala
+++ b/src/plugins/media-export/rygel-media-export-root-container.vala
@@ -125,7 +125,9 @@ public class Rygel.MediaExport.RootContainer : Rygel.MediaExport.DBContainer {
if (object == null && id.has_prefix (QueryContainer.PREFIX)) {
var factory = QueryContainerFactory.get_default ();
var container = factory.create_from_id (this.media_db, id);
- container.parent = this;
+ if (container != null) {
+ container.parent = this;
+ }
return container;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]