From 636c68c68df002147ad0618978202c0a14e22fea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Minisini?= Date: Sat, 21 Nov 2015 04:54:45 +0000 Subject: [PATCH] [DEVELOPMENT ENVIRONMENT] * BUG: Image editor: Fix crashes with selections having no extents. git-svn-id: svn://localhost/gambas/trunk@7485 867c0c6c-44f3-4631-809d-bfa615b0a4ec --- .../.src/Editor/Image/CImageSelection.class | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/app/src/gambas3/.src/Editor/Image/CImageSelection.class b/app/src/gambas3/.src/Editor/Image/CImageSelection.class index 204c57e9c..6ce40ad5e 100644 --- a/app/src/gambas3/.src/Editor/Image/CImageSelection.class +++ b/app/src/gambas3/.src/Editor/Image/CImageSelection.class @@ -650,14 +650,20 @@ Public Sub GetExtents(Optional bAll As Boolean) As RectF Dim hRect As RectF Dim I As Integer + Dim hRectShape As RectF If Shapes.Count = 0 Then Return New RectF If Current >= 0 And If Not bAll Then Return Shapes[Current].GetExtents() - hRect = Shapes[0].GetExtents() - For I = 1 To Shapes.Max - hRect = hRect.Union(Shapes[I].GetExtents()) + For I = 0 To Shapes.Max + hRectShape = Shapes[I].GetExtents() + If Not hRectShape Then Continue + If Not hRect Then + hRect = hRectShape + Else + hRect = hRect.Union(hRectShape) + Endif Next Return hRect @@ -668,6 +674,7 @@ Public Sub GetExtentsInt(Optional bAll As Boolean) As Rect Dim hExt As RectF = GetExtents(bAll) + If Not hExt Then Return Return Rect(Floor(hExt.X), Floor(hExt.Y), Ceil(hExt.Right) - Floor(hExt.X), Ceil(hExt.Bottom) - Floor(hExt.Y)) End @@ -718,6 +725,8 @@ Public Sub HFlip() Dim hMatrix As New PaintMatrix Dim hExt As RectF = GetExtents() + If Not hExt Then Return + hMatrix.Translate(hExt.X + hExt.W / 2, hExt.Y + hExt.H / 2) hMatrix.Scale(-1, 1) hMatrix.Translate(- (hExt.X + hExt.W / 2), - (hExt.Y + hExt.H / 2)) @@ -730,6 +739,8 @@ Public Sub VFlip() Dim hMatrix As New PaintMatrix Dim hExt As RectF = GetExtents() + If Not hExt Then Return + hMatrix.Translate(hExt.X + hExt.W / 2, hExt.Y + hExt.H / 2) hMatrix.Scale(1, -1) hMatrix.Translate(- (hExt.X + hExt.W / 2), - (hExt.Y + hExt.H / 2)) @@ -742,6 +753,8 @@ Public Sub Rotate(fAngle As Float) Dim hMatrix As New PaintMatrix Dim hExt As RectF = GetExtents() + If Not hExt Then Return + hMatrix.Translate(hExt.X + hExt.W / 2, hExt.Y + hExt.H / 2) hMatrix.Rotate(fAngle) hMatrix.Translate(- (hExt.X + hExt.W / 2), - (hExt.Y + hExt.H / 2)) @@ -754,6 +767,8 @@ Public Sub Scale(SX As Float, SY As Float, Optional bTopLeft As Boolean) Dim hMatrix As New PaintMatrix Dim hExt As RectF = GetExtents() + If Not hExt Then Return + If bTopLeft Then hMatrix.Translate(hExt.X, hExt.Y) Else @@ -907,8 +922,11 @@ Public Sub Duplicate() Dim hShape As CImageShape Dim DX, DY As Float Dim hMatrix As New PaintMatrix + Dim hExt As RectF = GetExtents() - With GetExtents() + If Not hExt Then Return + + With hExt DX = .W / 2 DY = .H / 2 End With