[futurebasic] Re: [FB] Urgent Call DisposeGWorld() Problem

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : May 1999 : Group Archive : Group : All Groups

From: Rick Brown <rbrown@...>
Date: Thu, 27 May 1999 21:22:01 -0500

Peuapeu@... wrote:

> The crash always happens in a Call DisposeGWorld(handle&) statement.

I'm assuming you mean "pointer" and not "handle" here.  GWorlds are always in
non-relocatable (pointer-type) blocks, never in relocatable (handle-type)
blocks.  If the thing you're passing to DisposeGWorld is really a handle, you're
definitely in trouble there.  If the thing you're passing is the same thing you
got back from NewGWorld (which is a pointer), you should be OK.

Try to verify that the GWorld you're disposing is not the current port--I'm not
sure what behavior to expect if you dispose of the current port.  The current
port can change at unexpected times, so just to be safe, you might try
explicitly setting the current port just before the DisposeGWorld call.  You can
do this using an FB WINDOW statement or the Toolbox routine SetPort.

>  Macsbug breaks out (sometimes several times) with the following:
> "DisposeHandle on a handle with a resource bit set".

Although the GWorld itself is not a handle, DisposeGWorld disposes of several
related handles, including the GWorld's pixel map, its color table, etc.  The
message you're getting sounds like one of those handles is a handle to a
resource.

For example, when you call NewGWorld, you can pass the handle to a color table
as one of the parameters.  Now, it's not clear to me from the "Inside Mac"
description whether the newly created GWorld makes its own private copy of that
color table, or just adopts the handle that you pass it--but if the latter is
the case, and that ctable handle happens to be a resource handle, then that
would explain the message.  If you think you are passing any resource handles to
NewGWorld, then first call "DetachResource" on them, just to be safe.
"DetachResource" causes the handle to be disassociated from the resource file,
while still keeping the handle's data intact in memory.

That's all I can think of--hope it helps.

- Rick