[hyena] Gui: Prevent NRE in RoundedFrame
- From: AndrÃs Aragoneses <aaragoneses src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [hyena] Gui: Prevent NRE in RoundedFrame
- Date: Sun, 23 Oct 2011 15:50:34 +0000 (UTC)
commit 2273ff3c52a75388e7e8aa8034d03e1bec1ec002
Author: AndrÃs G. Aragoneses <knocte gmail com>
Date: Sun Oct 23 16:46:44 2011 +0100
Gui: Prevent NRE in RoundedFrame
From the NRE stacktrace in bgo#630537 we
can infer that the theme field could be
accessed without being initialized, then
in this commit we will access the property
instead, doing null-guarding in the getter.
(Hopefully the last fix for this bug then.)
Hyena.Gui/Hyena.Widgets/RoundedFrame.cs | 25 +++++++++++++++++--------
1 files changed, 17 insertions(+), 8 deletions(-)
---
diff --git a/Hyena.Gui/Hyena.Widgets/RoundedFrame.cs b/Hyena.Gui/Hyena.Widgets/RoundedFrame.cs
index ac28bf0..2c9a8f1 100644
--- a/Hyena.Gui/Hyena.Widgets/RoundedFrame.cs
+++ b/Hyena.Gui/Hyena.Widgets/RoundedFrame.cs
@@ -40,7 +40,17 @@ namespace Hyena.Widgets
{
private Theme theme;
protected Theme Theme {
- get { return theme; }
+ get {
+ if (theme == null) {
+ InitTheme ();
+ }
+ return theme;
+ }
+ }
+
+ private void InitTheme () {
+ theme = Hyena.Gui.Theming.ThemeEngine.CreateTheme (this);
+ frame_width = (int)theme.Context.Radius + 1;
}
private Widget child;
@@ -91,8 +101,7 @@ namespace Hyena.Widgets
protected override void OnStyleSet (Style previous_style)
{
base.OnStyleSet (previous_style);
- theme = Hyena.Gui.Theming.ThemeEngine.CreateTheme (this);
- frame_width = (int)theme.Context.Radius + 1;
+ InitTheme ();
}
protected override void OnSizeRequested (ref Requisition requisition)
@@ -169,15 +178,15 @@ namespace Hyena.Widgets
Gdk.Rectangle rect = new Gdk.Rectangle (x, y, width, height);
- theme.Context.ShowStroke = draw_border;
+ Theme.Context.ShowStroke = draw_border;
if (fill_color_set) {
- theme.DrawFrameBackground (cr, rect, fill_color);
+ Theme.DrawFrameBackground (cr, rect, fill_color);
} else if (fill_pattern != null) {
- theme.DrawFrameBackground (cr, rect, fill_pattern);
+ Theme.DrawFrameBackground (cr, rect, fill_pattern);
} else {
- theme.DrawFrameBackground (cr, rect, true);
- theme.DrawFrameBorder (cr, rect);
+ Theme.DrawFrameBackground (cr, rect, true);
+ Theme.DrawFrameBorder (cr, rect);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]