From 9e263cdb7fe1290707674a98448b7fa5e81fa164 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Changsen=20XU=20=E5=BE=90=E6=98=B6=E6=A3=AE?=
 <45329228+xucs007@users.noreply.github.com>
Date: Tue, 1 Aug 2023 22:36:41 +0800
Subject: [PATCH] fix #669: dmledit crash on resize (#672)

---
 src/dlangui/widgets/layouts.d | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/dlangui/widgets/layouts.d b/src/dlangui/widgets/layouts.d
index 13d1b09d..22721068 100644
--- a/src/dlangui/widgets/layouts.d
+++ b/src/dlangui/widgets/layouts.d
@@ -519,10 +519,14 @@ class ResizerWidget : Widget {
     private void resizeAndFireEvent(short newWidth, ResizerEventType type)
     {
         // Respect the dimensions
-        if(newWidth > minPreviousItemWidth && newWidth < (parent.width - minWidth - minNextItemWidth) &&
-           newWidth > _previousWidget.minWidth() && newWidth < (parent.width - minWidth - _nextWidget.minWidth()))
+        if( (newWidth > minPreviousItemWidth) && (newWidth < (parent.width - minWidth - minNextItemWidth)) && (_previousWidget is null ||
+           ( (newWidth > _previousWidget.minWidth) && 
+	     (newWidth < (parent.width - minWidth - _nextWidget.minWidth))
+	    )))
         {
-            _previousWidget.layoutWidth = newWidth;
+	    if (_previousWidget !is null) {
+		_previousWidget.layoutWidth = newWidth;
+	    }
             if (resizeEvent.assigned)
             {
                resizeEvent(this, type, newWidth);