Skip to content

Commit

Permalink
Fix: Screenshot memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
PassiveLemon committed Jan 15, 2025
1 parent b3c9c65 commit 65a1f66
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
}:
buildNimPackage (finalAttrs: {
pname = "webfisher";
version = "0.2.0";
version = "0.2.1";

src = ./.;

Expand Down
2 changes: 1 addition & 1 deletion src/webfisher/meta.nim
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
let
releaseVersion* = "0.2.0"
releaseVersion* = "0.2.1"

3 changes: 2 additions & 1 deletion src/webfisher/screen.nim
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ proc getScreenshot(): PXImage =

proc getPixelColor(screenshot: PXImage; x: int; y: int): Pixel =
var pixel: Pixel

pixel.color = XGetPixel(screenshot, x.cint, y.cint)
pixel.r = ((pixel.color shr 16) and 0xFF).int
pixel.g = ((pixel.color shr 8) and 0xFF).int
Expand All @@ -61,6 +60,7 @@ proc getFishingGame*(): bool =
pixel.b == reelPixel.b:
# We test if at least 3 of the pixels match since the reel could block the pixel
valid += 1
discard XDestroyImage(screenshot)
if valid >= 3:
return true
else:
Expand All @@ -76,6 +76,7 @@ proc getCatchMenu*(): bool =
pixel.g == menuPixel.g and
pixel.b == menuPixel.b:
valid += 1
discard XDestroyImage(screenshot)
if valid >= 3:
return true
else:
Expand Down
2 changes: 1 addition & 1 deletion webfisher.nimble
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Package
version = "0.2.0"
version = "0.2.1"
author = "PassiveLemon"
description = "A Nim based fishing script for Webfishing"
license = "GPL-3.0-only"
Expand Down

0 comments on commit 65a1f66

Please sign in to comment.