mirror of
				https://gitlab.com/freepascal.org/fpc/source.git
				synced 2025-10-31 03:11:39 +01:00 
			
		
		
		
	Makes IntersectRect more robust. See bug #17722
git-svn-id: trunk@16224 -
This commit is contained in:
		
							parent
							
								
									4579226771
								
							
						
					
					
						commit
						b4b9354468
					
				| @ -344,25 +344,30 @@ end; | |||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| function IntersectRect(var Rect : TRect;const R1,R2 : TRect) : Boolean; | function IntersectRect(var Rect : TRect;const R1,R2 : TRect) : Boolean; | ||||||
| 
 | var | ||||||
|  |   lR1, lR2: TRect; | ||||||
| begin | begin | ||||||
|   Rect:=R1; |   // We copy the parameter to a local variables to avoid problems | ||||||
|   with R2 do |   // when passing the same rectangle in the var and const parameters. | ||||||
|     begin |   // See http://bugs.freepascal.org/view.php?id=17722 | ||||||
|     if Left>R1.Left then |   lR1 := R1; | ||||||
|       Rect.Left:=Left; |   lR2 := R2; | ||||||
|     if Top>R1.Top then | 
 | ||||||
|       Rect.Top:=Top; |   Rect := lR1; | ||||||
|     if Right<R1.Right then |   if lR2.Left > lR1.Left then | ||||||
|       Rect.Right:=Right; |     Rect.Left := lR2.Left; | ||||||
|     if Bottom<R1.Bottom then |   if lR2.Top > R1.Top then | ||||||
|       Rect.Bottom:=Bottom; |     Rect.Top := lR2.Top; | ||||||
|     end; |   if lR2.Right < R1.Right then | ||||||
|  |     Rect.Right := lR2.Right; | ||||||
|  |   if lR2.Bottom < R1.Bottom then | ||||||
|  |     Rect.Bottom := lR2.Bottom; | ||||||
|  | 
 | ||||||
|   if IsRectEmpty(Rect) then |   if IsRectEmpty(Rect) then | ||||||
|     begin |   begin | ||||||
|     FillChar(Rect,SizeOf(Rect),0); |     FillChar(Rect,SizeOf(Rect),0); | ||||||
|     IntersectRect:=false; |     IntersectRect:=false; | ||||||
|     end |   end | ||||||
|   else |   else | ||||||
|     IntersectRect:=true; |     IntersectRect:=true; | ||||||
| end; | end; | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 sekelsenmat
						sekelsenmat