Crash on FreeBitMap when depth > 1?
3 Attachment(s)
This problem has been driving me nuts for a while, but I want to get back into my program and finish it up (for a given definition of "finish") now that 3.2 is out.
Here's what's happening: - I open a screen with interleaved bitmap mode (SA_Interleaved=true) - I load IFFs from deluxepaint into bitmaps - I use those as "icons" on the screen, and user can drag them around. - On app shutdown, I go through all my "icon" objects, and free them. - In freeing icons, I call FreeBitMap - if I am in depth 1, it is fine. no crash. - if depth is 3, it crashes every single time. Looking at the bitmap structures in Bebbo's GCC toolchain debugger, they look the way I would expect them to: - the single depth bitmap has one plane. - the depth 3 interleaved bitmap has 3 planes, and they start offset from each by one word. My guess is that freebitmap frees the first plane, and that hoses the 2nd and 3rd plane, so they cause a crash, but I'm just guessing. And that seems weird to me, that the system wouldn't know what to do with interleaved bitmaps. So it's probably something I'm doing that I don't know I'm doing, but what? Here's is how I'm creating the bitmaps: Code:
// attempt to load and process the icon and mask data Code:
// copy the bitmap using the blitter Code:
if (the_icon->bitmap_ != NULL) |
AllocBitMap() does all the work, you shouldn't call InitBitMap() afterwards because it will mess up the bitmap structure (it will mark it as non-interleaved: pad is set to 0 and not to a magic word indicating interleaved bitmap).
|
Thanks a/b! So nice to be able to exit the app without a system crash again. ;)
So... is there still a use case for InitBitMap, or was it really kind of made unnecessary by the AllocBitMap() call? I seem to remember that there was a point where that didn't exist, and you had it init each bitplane. Fuzzy. |
It's an old KS1.x call that you can use it if you're allocating manually (or use static buffers). As long as it's not interleaved because InitBitMap cannot know that (it would need another parameter so you could e.g. pass the flags), and didn't really have to because at the time interleaved bitmaps hadn't been supported out of the box.
You could do some hocus-pocus with bitmap->pad afterwards to fix that but it's not really a good idea :P. |
I have enough bad ideas of my own, don't think I'll add that one. ;)
Thanks! |
All times are GMT +2. The time now is 23:40. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.