QB64.org Forum

Active Forums => QB64 Discussion => Topic started by: Petr on November 02, 2020, 01:09:44 pm

Title: Warning of a small bug in SaveImage
Post by: Petr on November 02, 2020, 01:09:44 pm
What is the latest version of SaveImage? There is a minor bug in the version that is published in the samples section. There is a fixed channel number to open the JPG file, it must be replaced by the number assigned by the FREEFILE function. See lines 619 and 628 of the BM file. It made mistakes in my program (channel 1 was already open for something else).
Title: Re: Warning of a small bug in SaveImage
Post by: SMcNeill on November 02, 2020, 02:52:03 pm
I’ll be back home tomorrow, so I’ll dig into the source then to see if the glitch is in the last version available.  If so, I’ll make a quick patch and fix the issue and make it available for everyone.  This bug, for a change, sounds like it’d be a breeze to fix.  ;D
Title: Re: Warning of a small bug in SaveImage
Post by: SMcNeill on November 03, 2020, 02:53:57 pm
Digging into this now.  You're correct; it's an oversight in the program.  This should definitely use a FREEFILE handle here, to prevent issues.  All the other save image routines do, but this one in particular (the JPG save image code) had a hard coded file handle of 1 it relied upon, which, as you said, can cause issues.

I'm also surprised that line 685 didn't toss issues for you, as it was a CLOSE statement, without any parameters to it.  As it currently exists, it'll close every open file out there in your program, and not just the JPG file which it creates.  That's doing just a weeee bit more than intended.

A fix for these will be coming soon(tm).