[longomatch] Fix exception when no image is selected



commit 3ea89e3c03bb8bc0c32fdd601ae65a481b4962b0
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Mon Mar 24 19:00:20 2014 +0100

    Fix exception when no image is selected

 LongoMatch.GUI/Gui/Component/TeamTemplateEditor.cs |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)
---
diff --git a/LongoMatch.GUI/Gui/Component/TeamTemplateEditor.cs 
b/LongoMatch.GUI/Gui/Component/TeamTemplateEditor.cs
index 9838fe3..2a678de 100644
--- a/LongoMatch.GUI/Gui/Component/TeamTemplateEditor.cs
+++ b/LongoMatch.GUI/Gui/Component/TeamTemplateEditor.cs
@@ -252,11 +252,14 @@ namespace LongoMatch.Gui.Component
 
                void HandlePlayerButtonPressEvent (object o, ButtonPressEventArgs args)
                {
-                       Image player = new Image (Helpers.Misc.OpenImage (this));
-                       if (player == null) {
+                       Image player;
+                       Pixbuf pix = Helpers.Misc.OpenImage (this);
+                       
+                       if (pix == null) {
                                return;
                        }
                        
+                       player = new Image (pix);
                        player.Scale (Constants.MAX_PLAYER_ICON_SIZE, Constants.MAX_PLAYER_ICON_SIZE); 
                        if (player != null && loadedPlayer != null) {
                                playerimage.Pixbuf = player.Value;
@@ -269,11 +272,14 @@ namespace LongoMatch.Gui.Component
 
                void HandleShieldButtonPressEvent (object o, ButtonPressEventArgs args)
                {
-                       Image shield = new Image (Helpers.Misc.OpenImage (this));
-                       if (shield == null) {
+                       Image shield;
+                       Pixbuf pix = Helpers.Misc.OpenImage (this);
+                       
+                       if (pix == null) {
                                return;
                        }
                        
+                       shield = new Image (pix);
                        shield.Scale (Constants.MAX_SHIELD_ICON_SIZE, Constants.MAX_SHIELD_ICON_SIZE); 
                        if (shield != null)
                        {


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