[hyena] Gui.Canvas.Size: log invalid values for Width/Height (bgo#661112)



commit 20ef00dae30cfe1d8edc6cb4c6f13ece5df015e8
Author: Andres G. Aragoneses <knocte gmail com>
Date:   Thu Sep 13 20:14:00 2012 +0100

    Gui.Canvas.Size: log invalid values for Width/Height (bgo#661112)
    
    In the same vein as other hard to reproduce bugs, logging the exception
    and adjusting in the safest way possible can make hyena consumers (Banshee
    in this case) not crash.
    
    Signed-off-by: Bertrand Lorentz <bertrand lorentz gmail com>

 Hyena.Gui/Hyena.Gui.Canvas/Size.cs |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/Hyena.Gui/Hyena.Gui.Canvas/Size.cs b/Hyena.Gui/Hyena.Gui.Canvas/Size.cs
index b626597..542e926 100644
--- a/Hyena.Gui/Hyena.Gui.Canvas/Size.cs
+++ b/Hyena.Gui/Hyena.Gui.Canvas/Size.cs
@@ -74,7 +74,9 @@ namespace Hyena.Gui.Canvas
             get { return height; }
             set {
                 if (value < 0) {
-                    throw new ArgumentException ();
+                    Log.Exception (String.Format ("Height value to set: {0}", value),
+                                   new ArgumentException ("Height setter should not receive negative values", "value"));
+                    value = 0;
                 }
 
                 height = value;
@@ -85,7 +87,9 @@ namespace Hyena.Gui.Canvas
             get { return width; }
             set {
                 if (value < 0) {
-                    throw new ArgumentException ();
+                    Log.Exception (String.Format ("Width value to set: {0}", value),
+                                   new ArgumentException ("Width setter should not receive negative values", "value"));
+                    value = 0;
                 }
 
                 width = value;



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