From 9d608db4b0074443ed92974bff7706307c767e9f Mon Sep 17 00:00:00 2001 From: Jerome St-Louis Date: Sun, 9 Feb 2014 11:13:44 +0700 Subject: [PATCH] ecere/gui/Window;ListBox: Null safety checks --- ecere/src/gui/Window.ec | 6 +++--- ecere/src/gui/controls/ListBox.ec | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ecere/src/gui/Window.ec b/ecere/src/gui/Window.ec index 336b21f..7977ff7 100644 --- a/ecere/src/gui/Window.ec +++ b/ecere/src/gui/Window.ec @@ -8721,7 +8721,7 @@ public: if(parent && parent.created && !nonClient) parent.OnChildResized(this, x, y, w, h); } } - get { value = clientSize; } + get { value = this ? clientSize : { 0, 0 }; } }; property Size initSize { get { value = sizeAnchor.size; } }; @@ -9173,7 +9173,7 @@ public: property Point scroll { property_category $"Behavior" - set { SetScrollPosition(value.x, value.y); } + set { if(this) SetScrollPosition(value.x, value.y); } get { value = scroll; } }; @@ -9336,7 +9336,7 @@ public: property Font fontObject { get { return usedFont ? usedFont.font : null; } }; property Point clientStart { get { value = clientStart; } }; property Point absPosition { get { value = absPosition; } }; - property Anchor normalAnchor { get {value = normalAnchor; } }; + property Anchor normalAnchor { get { value = normalAnchor; } }; // property Size normalSizeAnchor { get { value = normalSizeAnchor; } }; property bool active { get { return (bool)active; } }; property bool created { get { return (bool)created; } }; diff --git a/ecere/src/gui/controls/ListBox.ec b/ecere/src/gui/controls/ListBox.ec index 845fbdc..77cd9f8 100644 --- a/ecere/src/gui/controls/ListBox.ec +++ b/ecere/src/gui/controls/ListBox.ec @@ -258,7 +258,7 @@ public class DataRow bool skipCheck; #endif public: - property int64 tag { set { tag = value; } get { return tag; } }; + property int64 tag { set { if(this) tag = value; } get { return this ? tag : 0; } }; property DataRow previous { get { return prev; } }; property DataRow next { get { return next; } }; property int index { get { return (this && (!parent || parent.IsExpanded())) ? index : -1; } }; @@ -268,12 +268,12 @@ public: get { return GetData(listBox.fields.first); } }; property bool isHeader { set { header = value; } get { return this ? header : false; } }; - property BitmapResource icon { set { icon = value; } get { return icon; } }; + property BitmapResource icon { set { if(this) icon = value; } get { return this ? icon : null; } }; property bool collapsed { set { - if(collapsed != value) + if(this && collapsed != value) { collapsed = value; if(parent.IsExpanded()) @@ -321,7 +321,7 @@ public: } } #ifdef _DEBUG - if(!skipCheck) + if(this && !skipCheck) listBox.CheckConsistency(); #endif } @@ -964,7 +964,7 @@ public class ListBox : CommonControl public: // Properties property bool freeSelect { property_category $"Behavior" set { style.freeSelect = value; } get { return style.freeSelect; } }; - property DataRow currentRow { property_category $"Private" /*"Behavior"*/ set { SetCurrentRow(value, false); } get { return currentRow; } }; + property DataRow currentRow { property_category $"Private" /*"Behavior"*/ set { if(this) SetCurrentRow(value, false); } get { return this ? currentRow : null; } }; property DataField currentField { get { return currentField; } @@ -997,7 +997,7 @@ public: OnApplyGraphics(); } } - get { return rowHeight; } + get { return this ? rowHeight : 0; } }; property Seconds typingTimeout { @@ -1967,7 +1967,7 @@ private: void SetCurrentRow(DataRow row, bool notify) { - if(currentRow != row || (currentRow && currentRow.selectedFlag == unselected)) + if(this && (currentRow != row || (currentRow && currentRow.selectedFlag == unselected))) { int headerSize = ((style.header) ? rowHeight : 0); int height = clientSize.h + 1 - headerSize; -- 1.8.3.1