[longomatch] Check for null setting images
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch] Check for null setting images
- Date: Sun, 18 Dec 2011 21:42:50 +0000 (UTC)
commit b8c2869339176b7a13f0e288e76a78bb725d617c
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Sun Dec 11 21:44:19 2011 +0100
Check for null setting images
LongoMatch.Core/Store/PixbufTimeNode.cs | 2 +-
LongoMatch.GUI/Gui/Component/PlayerProperties.cs | 2 +-
LongoMatch.GUI/Gui/Component/ProjectListWidget.cs | 2 +-
LongoMatch.GUI/Gui/TreeView/ListTreeViewBase.cs | 14 +++++++++-----
.../Gui/TreeView/PlayerPropertiesTreeView.cs | 2 +-
5 files changed, 13 insertions(+), 9 deletions(-)
---
diff --git a/LongoMatch.Core/Store/PixbufTimeNode.cs b/LongoMatch.Core/Store/PixbufTimeNode.cs
index 7bcd93d..b9feb25 100644
--- a/LongoMatch.Core/Store/PixbufTimeNode.cs
+++ b/LongoMatch.Core/Store/PixbufTimeNode.cs
@@ -51,7 +51,7 @@ namespace LongoMatch.Store
return Image.Deserialize(thumbnailBuf);
else return null;
} set {
- thumbnailBuf = value.Serialize();
+ thumbnailBuf = value == null ? null: value.Serialize();
}
}
diff --git a/LongoMatch.GUI/Gui/Component/PlayerProperties.cs b/LongoMatch.GUI/Gui/Component/PlayerProperties.cs
index b5abd2f..970338d 100644
--- a/LongoMatch.GUI/Gui/Component/PlayerProperties.cs
+++ b/LongoMatch.GUI/Gui/Component/PlayerProperties.cs
@@ -61,7 +61,7 @@ namespace LongoMatch.Gui.Component
numberspinbutton.Value = value.Number;
weightspinbutton.Value = value.Weight;
heightspinbutton.Value = value.Height;
- image.Pixbuf = value.Photo.Value;
+ image.Pixbuf = value.Photo != null ? value.Photo.Value : null;
playscombobox.Active = value.Playing ? 0 : 1;
}
get {
diff --git a/LongoMatch.GUI/Gui/Component/ProjectListWidget.cs b/LongoMatch.GUI/Gui/Component/ProjectListWidget.cs
index a9f01b7..2193ba5 100644
--- a/LongoMatch.GUI/Gui/Component/ProjectListWidget.cs
+++ b/LongoMatch.GUI/Gui/Component/ProjectListWidget.cs
@@ -107,7 +107,7 @@ namespace LongoMatch.Gui.Component
{
ProjectDescription project = (ProjectDescription) model.GetValue(iter, 0);
- (cell as Gtk.CellRendererPixbuf).Pixbuf= project.File.Preview.Value;
+ (cell as Gtk.CellRendererPixbuf).Pixbuf= project.File.Preview != null ? project.File.Preview.Value : null;
}
private void RenderProperties(Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, Gtk.TreeIter iter)
diff --git a/LongoMatch.GUI/Gui/TreeView/ListTreeViewBase.cs b/LongoMatch.GUI/Gui/TreeView/ListTreeViewBase.cs
index 5bad23d..e76ab50 100644
--- a/LongoMatch.GUI/Gui/TreeView/ListTreeViewBase.cs
+++ b/LongoMatch.GUI/Gui/TreeView/ListTreeViewBase.cs
@@ -16,14 +16,16 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
//
+using System;
+using System.Collections.Generic;
using Gdk;
using Gtk;
+using Mono.Unix;
+
+using Image = LongoMatch.Common.Image;
using LongoMatch.Common;
using LongoMatch.Handlers;
using LongoMatch.Store;
-using Mono.Unix;
-using System;
-using System.Collections.Generic;
namespace LongoMatch.Gui.Component
{
@@ -151,7 +153,8 @@ namespace LongoMatch.Gui.Component
var c = cell as CellRendererPixbuf;
if(item is Play) {
- c.Pixbuf = (item as Play).Miniature.Value;
+ Image img = (item as Play).Miniature;
+ c.Pixbuf = img != null ? img.Value : null;
if(Colors) {
c.CellBackgroundGdk = Helpers.ToGdkColor((item as Play).Category.Color);
} else {
@@ -159,7 +162,8 @@ namespace LongoMatch.Gui.Component
}
}
else if(item is Player) {
- c.Pixbuf= (item as Player).Photo.Value;
+ Image img = (item as Player).Photo;
+ c.Pixbuf = img != null ? img.Value : null;
c.CellBackground = "white";
}
else {
diff --git a/LongoMatch.GUI/Gui/TreeView/PlayerPropertiesTreeView.cs b/LongoMatch.GUI/Gui/TreeView/PlayerPropertiesTreeView.cs
index 7bbb3b9..51c367f 100644
--- a/LongoMatch.GUI/Gui/TreeView/PlayerPropertiesTreeView.cs
+++ b/LongoMatch.GUI/Gui/TreeView/PlayerPropertiesTreeView.cs
@@ -113,7 +113,7 @@ namespace LongoMatch.Gui.Component
{
Player player = (Player) model.GetValue(iter, 0);
- (cell as Gtk.CellRendererPixbuf).Pixbuf = player.Photo.Value;
+ (cell as Gtk.CellRendererPixbuf).Pixbuf = player.Photo != null ? player.Photo.Value : null;
}
private void RenderName(Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, Gtk.TreeIter iter)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]