Welcome to MacForumz.com!
FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Help! DisposeGWorld is killing me!

 
   Macintosh computer (Home) -> Graphics RSS
Next:  Open Type?  
Author Message
Edward de Jong

External


Since: Apr 02, 2004
Posts: 6



(Msg. 1) Posted: Tue Jul 27, 2004 10:59 pm
Post subject: Help! DisposeGWorld is killing me!
Archived from groups: comp>sys>mac>graphics (more info?)

I am programming a Carbon and classic application.

I am extremely frustrated after eight solid hours chasing a problem, and
still no end in sight. I have boiled the problem down to a single line of
code - a call to DisposeGWorld. The problem is the GWorld is a normally
created Gworld. it is 8 bits in depth, and I gave it a color table to use
(but no device, assuming it will build one). I use the same pmTable value
for many of my other gworlds and pixmaps, as I am using a grayscale color
table for use in generating masks. Anway, the DisposeGWorld call smashes
memory somehow, and shortly thereafter my program goes cosmic, and i can't
figure out why the DisposeGWorld call is ruining my life.

I read about how if you call DisposeGWorld using the currently selected
port, it will kill you. I realize this but i put a GetPort(p); IF p =
gworld_being_discard THEN quit statement so I could catch any stupid error
of this kind.

Anyone else suffered through this? Is there something about 8-bit GWorlds
and their color tables that is particularly tricky?

A prize to whoever helps me solve this first.

edj

 >> Stay informed about: Help! DisposeGWorld is killing me! 
Back to top
Login to vote
Kevin McMurtrie1

External


Since: Sep 07, 2003
Posts: 305



(Msg. 2) Posted: Tue Jul 27, 2004 11:52 pm
Post subject: Re: Help! DisposeGWorld is killing me! [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

In article <BD2C80BB.394F5%edward@magicmouse.com>,
Edward de Jong <edward.RemoveThis@magicmouse.com> wrote:

 > I am programming a Carbon and classic application.
 >
 > I am extremely frustrated after eight solid hours chasing a problem, and
 > still no end in sight. I have boiled the problem down to a single line of
 > code - a call to DisposeGWorld. The problem is the GWorld is a normally
 > created Gworld. it is 8 bits in depth, and I gave it a color table to use
 > (but no device, assuming it will build one). I use the same pmTable value
 > for many of my other gworlds and pixmaps, as I am using a grayscale color
 > table for use in generating masks. Anway, the DisposeGWorld call smashes
 > memory somehow, and shortly thereafter my program goes cosmic, and i can't
 > figure out why the DisposeGWorld call is ruining my life.
 >
 > I read about how if you call DisposeGWorld using the currently selected
 > port, it will kill you. I realize this but i put a GetPort(p); IF p =
 > gworld_being_discard THEN quit statement so I could catch any stupid error
 > of this kind.
 >
 > Anyone else suffered through this? Is there something about 8-bit GWorlds
 > and their color tables that is particularly tricky?
 >
 > A prize to whoever helps me solve this first.
 >
 > edj

Have you attached any shared resources to it, like a system color table
or the main GDevice? DisposeGWorld will delete that too and make a
serious mess of your app environment. You need to either duplicate
resources or detach them before calling DisposeGWorld. Watch out for
deep disposal on shallow copies too. Your best bet is to step through
it in a debugger and see where the innards point to. At least in
Classic, Macsbug can tell you which heap a pointer or handle belongs to.

The newsgroups comp.sys.mac.programmer.help and
comp.sys.mac.programmer.codewarrior will probably be better resources.
Post some code in one.<!-- ~MESSAGE_AFTER~ -->

 >> Stay informed about: Help! DisposeGWorld is killing me! 
Back to top
Login to vote
Edward de Jong

External


Since: Apr 02, 2004
Posts: 6



(Msg. 3) Posted: Wed Jul 28, 2004 12:16 am
Post subject: Re: Help! DisposeGWorld is killing me! [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

I share the same color table throughout many uses, and wasn't aware that
DisposeGWorld would do anything with my color table that I passed to
NewGWorld. It should deallocate the GDevice it created, the Pixmap bits,

I am not using resources for color tables; they are all created in the
initialization phase of my program using NewHandle() and were filled in by
my custom code. It appears that only the 8-bit DisposeGWorld is killing my
machine.

I do a lot of 8-bit mask manipulation in GWorlds, and I set up a grayscale
color table at the beginning of my program, and use it throughout.

For some reason this particular DisposeGWorld is causing my program fits.
If I comment out the DisposeGWorld, and let the memory leak, the code works
okay.

After calling DisposeGWorld, my program eventually crashes in some later
call to CopyBits.

I thought perhaps that I was drawing into a disposed GWorld, but I don't
think so. The bad things happen in both Classic and Carbon. In carbon, I
eventually get a protection violation with tracing such as this:

Thread 0 Crashed:
#0 0x91a59e84 in SetupOffscreenDevice
#1 0x91a53f18 in Stretch
#2 0x91a5f168 in OneSrcOneDst
#3 0x91a59a90 in BitsDevLoop
#4 0x91a53868 in CommonBits
#5 0x91a59c88 in CopyBits <=== the entry into the toolbox
#6 0x0027fef0 in Pix_To_Pix
#7 0x001e86c8 in Apply_Subset
#8 0x001ea0d4 in 0x1ea0d4
#9 0x001eb3bc in Cache_Get2
#10 0x001eb8a8 in Cache_Get
#11 0x00292f18 in Photo_Calc_DstBox
#12 0x00292cb4 in Photo_Paste
#13 0x002c49d4 in Pack_OK
#14 0x00242ab4 in OneShot_Click
#15 0x0023b628 in Intf_MouseDown
#16 0x001d9f1c in Human_MouseDown
#17 0x001da78c in Main_Event_Handler
#18 0x001dab60 in Main_Loop
#19 0x001db31c in Do_Main
#20 0x001d90e0 in Discus
#21 0x003298b0 in 0x3298b0
#22 0x902790c4 in CCFM_LaunchApplication
#23 0x0000362c in main
#24 0x0000329c in _start
#25 0x0000311c in start
 >> Stay informed about: Help! DisposeGWorld is killing me! 
Back to top
Login to vote
Edward de Jong

External


Since: Apr 02, 2004
Posts: 6



(Msg. 4) Posted: Wed Jul 28, 2004 12:42 am
Post subject: Re: Help! DisposeGWorld is killing me! [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

It appears that I was copying the pmTable field from inside a GWorld into a
Pixmap, and disposing the GWorld, which caused horrible things to happen
eventually when that color table was accessed. Evidently the colortables
passed to NewGWorld are copied, so they can be deleted later on, and I
mistakenly thought DisposeGWorld didn't delete color tables.

edj
 >> Stay informed about: Help! DisposeGWorld is killing me! 
Back to top
Login to vote
Kevin McMurtrie1

External


Since: Sep 07, 2003
Posts: 305



(Msg. 5) Posted: Thu Jul 29, 2004 12:57 am
Post subject: Re: Help! DisposeGWorld is killing me! [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

In article <BD2C98E0.395CB%edward@magicmouse.com>,
Edward de Jong <edward.RemoveThis@magicmouse.com> wrote:

 > It appears that I was copying the pmTable field from inside a GWorld into a
 > Pixmap, and disposing the GWorld, which caused horrible things to happen
 > eventually when that color table was accessed. Evidently the colortables
 > passed to NewGWorld are copied, so they can be deleted later on, and I
 > mistakenly thought DisposeGWorld didn't delete color tables.
 >
 > edj

I worked on the Mac PointCast animation engine way back in 1997.
Unfortunately, the only way to get QuickDraw 32 working efficiently and
reliably was to step through it all in a debugger. There's very poor
documentation about who owns all of the interconnected data structures
and how to match them up to avoid extra buffering.

You're lucky to have hardware acceleration but the API is still prone to
memory corruption. Glad to hear that you found the bug. Good luck with
your project!<!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: Help! DisposeGWorld is killing me! 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Converting pict.jpg to jfif.jpg - have some JPEG-compressed PICT files. When I upload them to my Web site, browsers won't display them. Apparently, PICT is poorly supported. I'd like to put them on the Web without recompressing them. Is there a way to do that?

Problem with linked/grouped lines in Illustrator - I have a graphic, originally created as an EPS in Mathematica, which includes three separate lines/paths that all emanate from a common point, and I can't seem to ungroup or unlink them so as to apply separate colors and dashings. I can select each..

quicktime help for web - I'm not sure if this is the right place or not, if not maybe someone can direct me to the proper group. I have a panoramic file created by a program called ulead 360 as a mov file. This is a panoramic file. when played on QuickTime it looks odd, like ...

Apple Camera - digital recording for cctv - Hello - We have produced a digital stills camera for use with Apple computers than can take sequential snap shots of the camera scene at timed intervals for cctv purposes. We call the camera the Apple 'Crime-Buster'. The quality of the images produce...

Viewing Mac files on PC - Hello I am not to savvy on Mac's, and need a little information. My daughter does digital imaging in school on a Mac. So this is the question. She can not view files on her laptop(Windows XP Home) she saves on her flash drive after working in the..
   Macintosh computer (Home) -> Graphics All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]