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



commit 79c651265c82b1e7249649289222a681c593863e
Author: Andres G. Aragoneses <knocte gmail com>
Date:   Thu Sep 13 19:55:14 2012 +0100

    Gui.Canvas.Rect: log invalid values for Width/Height (bgo#624976)
    
    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.
    
    (Again, not ideal, but if the user reports success, it is better than
    not having this partial fix.)
    
    Signed-off-by: Bertrand Lorentz <bertrand lorentz gmail com>

 Hyena.Gui/Hyena.Gui.Canvas/Rect.cs |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/Hyena.Gui/Hyena.Gui.Canvas/Rect.cs b/Hyena.Gui/Hyena.Gui.Canvas/Rect.cs
index 3dc568b..3c60d3e 100644
--- a/Hyena.Gui/Hyena.Gui.Canvas/Rect.cs
+++ b/Hyena.Gui/Hyena.Gui.Canvas/Rect.cs
@@ -81,7 +81,9 @@ namespace Hyena.Gui.Canvas
             get { return w; }
             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;
                 }
 
                 w = value;
@@ -92,7 +94,9 @@ namespace Hyena.Gui.Canvas
             get { return h; }
             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;
                 }
 
                 h = value;



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