views:

257

answers:

1

I'm trying to write a simple component that will allow you to embed one or more SDL rendering surfaces on a Delphi window, using the SDL 1.3 APIs. It will compile and install just fine, but when I try to use the component in the form designer, it raises AVs whenever I try to access its properties in the object inspector, save the form, or delete the component, and placing one on a form then trying to run gives a linker error: it apparently can't read the DFM properly for whatever reason.

The DLL can be found at http://www.libsdl.org/tmp/SDL-1.3-dll.zip and the source code to my component can be downloaded here. SDL.pas is a JEDI-SDL header file; the rest is my own code.

I don't see any reason for this to raise AVs in the form designer. If I dynamically create the control at runtime I don't have any stability issues. Can anyone take a look at this and maybe provide some feedback that might help me clear it up?

+14  A: 

You can debug this yourself. Open the package project that contains your component. Then go to Run|Parameters and enter the IDE itself as the Host Application. Run the IDE from within the IDE. Then repeat your steps to reproduce the AV, and the IDE should stop and show you where things are failing. You can use normal debugging techniques from there.

Allen Bauer
OK. The problem goes away when I remove the Flags property from the published section. The IDE chokes when it tries to look up the RTTI for the underlying Set definition. I'm running Delphi 2009 with all the updates installed. This is the second case I've found of bad RTTI in '09. I'll put it in QC.
Mason Wheeler
How is the set declared? How many elements in the set? You can only publish sets that only contain up to 32 elements.
Allen Bauer
TSdlWindowFlags = set of (sdlwFullscreen, sdlwOpenGl, sdlwShown, sdlwBorderless, sdlwResizable, sdlwMinimized, sdlwMaximized, sdlwInputGrabbed, dslwInputFocus, sdlwMouseFocus, sdwlForeign, sdlwForce32 = 31); 12 elements in the enumeration, crafted so I can pass it to a C routine expecting an "int".
Mason Wheeler
The high element is never used, of course. But it doesn't overflow the 32-element limit. See http://qc.embarcadero.com/wc/qcmain.aspx?d=72070 for my bug report.
Mason Wheeler
Ah. It's a disconnected enumeration. The last element isn't contiguous. That is probably the cause since the RTTI doesn't handle non-contiguous enumerations and then sets created from them.
Allen Bauer
In that case, it shouldn't compile. Silently generating bad binary code is never right. BTW is there any other way to force a set to be a larger byte size than it would be otherwise?
Mason Wheeler
Looks like the last element, sdlwForce32 is just there to make sure the size is 32bits. If all you're doing is passing in this value to an API, it will still be passed in as 32bits if you just cast it to Integer.
Allen Bauer
If you pass in a reference and expect the API to fill in the value, you may have to manually use a temp and then cast it. Try to declare the enumeration as its own type, then create the set of that enum.
Allen Bauer
Meh. I declared it as a set specifically so I wouldn't have to do it as an integer. *shrug* Oh well. In this particular case, the set doesn't need to be published anyway. It would sure be nice to have a {$MINSETSIZE} directive (like {$MINENUMSIZE}) to make this work.
Mason Wheeler
(Submitted that one as 72093)
Mason Wheeler