1. Win32Lib bug in registerControl()
- Posted by ghaberek (admin) Mar 13, 2012
- 1327 views
So I've been playing around with custom controls, and I'm pretty sure I found bug. The documentation for registerControl() states:
However, in the code (around line 26296), there is this:
26296 lClass = call_func(pRID[kCRID_Control], {"classType", -1}) 26297 classAlias[lControl] = lClass 26298 classType[lControl] = classType[lClass]
If the "Control" routine returns the default -1 as stated in the docs, the application crashes since it is trying to use lClass as an index into classType.
C:\EUPHORIA\Win32Lib\Include\win32lib.ew:26298 in function registerControl() subscript value -1 is out of bounds, reading from a sequence of length 62
And I'm honestly not too sure how to go about fixing it.
-Greg
2. Re: Win32Lib bug in registerControl()
- Posted by DerekParnell (admin) Mar 13, 2012
- 1306 views
And I'm honestly not too sure how to go about fixing it.
Ok, that's my problem. I'll fix it tonight (in about 6-8 hours from now).
3. Re: Win32Lib bug in registerControl()
- Posted by ghaberek (admin) Mar 13, 2012
- 1290 views
Ok, that's my problem. I'll fix it tonight (in about 6-8 hours from now).
Poking around, I thought I could just add an if statement like this:
if lClass != -1 then classType[lControl] = classType[lClass] end if
...then things broke even worse later on.
C:\EUPHORIA\Win32Lib\Include\win32lib.ew:26314 in function registerControl() subscript value -1 is out of bounds, reading from a sequence of length 62
Which is this line:
26314 classKbdInput[lControl] = call_func(pRID[kCRID_Control], {"classKbdInput", classKbdInput[lClass]})
-Greg
4. Re: Win32Lib bug in registerControl()
- Posted by ghaberek (admin) Mar 13, 2012
- 1345 views
To recap on what I was doing (and perhaps provide some context on fixing the issue), I'm trying to create a custom Window class. One thing I noticed almost immediately is that I'm not receiving any thing into the "Process" routine, and I believe it's because I'm passing Window back for "controlType".
The question is, should I be receiving those messages using the Window type, or should I be passing back -1 for "controlType" to define my control as a "new" type? You can download what I've started on here:
Download: w32custom.zip (2 KB)
-Greg
5. Re: Win32Lib bug in registerControl()
- Posted by DerekParnell (admin) Mar 14, 2012
- 1265 views
So I've been playing around with custom controls, and I'm pretty sure I found bug. The documentation for registerControl() states:
However, in the code (around line 26296), there is this:
26296 lClass = call_func(pRID[kCRID_Control], {"classType", -1}) 26297 classAlias[lControl] = lClass 26298 classType[lControl] = classType[lClass]
If the "Control" routine returns the default -1 as stated in the docs, the application crashes since it is trying to use lClass as an index into classType.
C:\EUPHORIA\Win32Lib\Include\win32lib.ew:26298 in function registerControl() subscript value -1 is out of bounds, reading from a sequence of length 62
And I'm honestly not too sure how to go about fixing it.
-Greg
The fix is simple. The documentation is wrong. It should read ...
In other words, your new control must return a valid class type. If your new control's registration routine fails to do that, your application will crash.
6. Re: Win32Lib bug in registerControl()
- Posted by DerekParnell (admin) Mar 14, 2012
- 1265 views
To recap on what I was doing (and perhaps provide some context on fixing the issue), I'm trying to create a custom Window class. One thing I noticed almost immediately is that I'm not receiving any thing into the "Process" routine, and I believe it's because I'm passing Window back for "controlType".
Yep, this is a bug. There is a one-line change required in win32lib.ew.
Find the routine called "MessageProcessor" and look for the line ...
lTemp = ctrl_Type[id]
and change it to ...
lTemp = ctrl_ActualClass[id]