SCI Studio bug report

sith Hi,

I discovered a bug in SCI Studio 3.01

In the View editor I get the error "Canvas does not allow drawing", sometimes followed by the famous "Incorrect parameter" error.

This error occurs at random, so it's not easy to replicate. I'm running Win98SE.

Brian : Sorry to put this in the forum instead of e-mailing this, but I'm having email-troubles with my provider.


Brian_Provinciano Heh. All the bugs are due to Win98. hehe

Well, the good news is the traffic to my site last year was about 60% Win98, now it's about 60% WinXP. In all seriousness though, I will have them fixed when SCI Studio 3.1 is out since I'll do a lot of testing on a Win98 machine.
sith Brian,

Make sure you test long enough. The bug I mentioned appeared after working more than an hour in the view-editor.
AGI1122 Yeah I used to use 98, but now I use XP. ;D

Let's just say... I am never going back, I love XP. :)
Wilco23 I'm currently on Win95 and I've been having the same problem as Sith, in the view editor and picture editor. It does seem to just happen at random, "Canvas does not allow drawing" and "Paramater is ". The latter comes up a million times on my screen, so I have to press Ctrl + Alt + Delete to cancel SCI Studio on the taskmanager.
sith I've been doing some research myself and it seems that this bug is probably still a memory leak.

The "canvas does not allow drawing" could indicate that you're not cleaning up all the DC's you're allocating. (as a result, Windows cannot provide you with a valid DC anymore. I think there is a limit to the number of DC's a program can allocate, but I'm not sure.)

Brian, when you go to the next cell in a loop, do you create a new DC to draw the next view or do you use one DC that's updated every time ? In the first case, are you sure you free() the DC that's not in use anymore ?

Brian_Provinciano None of the Canvas errors come from my WinAPI. The Canvas is a Borland VCL component that locks itself sometimes, generating the error message. I will look into whether or not I can check if the canvas is locked before writing to it, possibly waiting for it to be ready to avoid the message. Borland's VCL is crap, but coding the whole UI in WinAPI would be like coding in assembly language.
sith Brian,

I found a Delphi help-file on the web and since Delphi also uses the VCL I think most of it is applicable to the C++ components too.

The TCanvas class has a method called TryLock()

form the helpfile :

Locks the canvas if it is currently unlocked.

function TryLock: Boolean;


Call TryLock to prevent other threads from writing on the surface of the canvas until the Unlock method is called. Unlike calls to the Lock method, which nest so that every call to Lock must be matched with a subsequent call to Unlock, TryLock need only be matched by a call to Unlock if the canvas was not already locked.

If the canvas is unlocked, TryLock locks the canvas, sets the LockCount property to 1, and returns True. If the canvas is already locked, TryLock returns False without making any changes.

Use TryLock before attempting changes to the canvas that could interfere with other code that is protected by a Lock ... Unlock pair of method calls.

I hope this helps you a little bit...

One question : Do you use multi-threading in SCI Studio ? Because if you do, you must be very careful with locking and unlocking resources.


PS : here are some free memory- and resourceleak-checkers
Drigo I guess it is e memory leak due to missing deallocations of memory just like Sith pointed 8)

In fact it happens in the font editor as well... to let it come out, you must display all the characters using the arrows, after having step through a pair dozen of chars you'll get the canvas error.

Also another bug happens when you change the font size, if you select the font size field bt don't change its value it is changed carelessy of your choice.

However, Brian rocks! ;)