From cad782738cf14ec7ba125ce0aa6313f9d5fcc21c Mon Sep 17 00:00:00 2001 From: vcaesar Date: Sat, 29 May 2021 09:58:26 -0400 Subject: [PATCH] update free bitmap fixed #333 --- robotgo.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/robotgo.go b/robotgo.go index 661c4a4..e0e2f40 100644 --- a/robotgo.go +++ b/robotgo.go @@ -978,7 +978,7 @@ func FindBitmap(bit C.MMBitmapRef, args ...interface{}) (int, int) { fx, fy := internalFindBitmap(bit, sbit, tolerance) // FreeBitmap(bit) - if len(args) <= 0 { + if len(args) <= 0 || (len(args) > 0 && args[0] == nil) { FreeBitmap(sbit) } @@ -1011,7 +1011,7 @@ func FindPic(path string, args ...interface{}) (int, int) { fx, fy := internalFindBitmap(openbit, sbit, tolerance) FreeBitmap(openbit) - if len(args) <= 0 { + if len(args) <= 0 || (len(args) > 0 && args[0] == nil) { FreeBitmap(sbit) } @@ -1056,7 +1056,7 @@ func FindEveryBitmap(bit C.MMBitmapRef, args ...interface{}) (posArr []MPoint) { pos := C.find_every_bitmap(bit, sbit, tolerance, &lpos) // FreeBitmap(bit) - if len(args) <= 0 { + if len(args) <= 0 || (len(args) > 0 && args[0] == nil) { FreeBitmap(sbit) } if pos == nil { @@ -1299,7 +1299,7 @@ func FindColor(color CHex, args ...interface{}) (int, int) { } pos := C.bitmap_find_color(bitmap, C.MMRGBHex(color), tolerance) - if len(args) <= 0 { + if len(args) <= 0 || (len(args) > 0 && args[0] == nil) { FreeBitmap(bitmap) } @@ -1356,7 +1356,7 @@ func FindEveryColor(color CHex, args ...interface{}) (posArr []MPoint) { } pos := C.bitmap_find_every_color(bitmap, C.MMRGBHex(color), tolerance, &lpos) - if len(args) <= 0 { + if len(args) <= 0 || (len(args) > 0 && args[0] == nil) { FreeBitmap(bitmap) } @@ -1396,7 +1396,7 @@ func CountColor(color CHex, args ...interface{}) int { } count := C.bitmap_count_of_color(bitmap, C.MMRGBHex(color), tolerance) - if len(args) <= 0 { + if len(args) <= 0 || (len(args) > 0 && args[0] == nil) { FreeBitmap(bitmap) }