<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>sub bitmaps</title>
		<link>http://www.allegro.cc/forums/view/550508</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Wed, 07 Dec 2005 06:00:31 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hello,<br />I&#39;ve created a bitmap that can be either memory, video or system. I then use create_sub_bitmap() to create sub bitmaps. All is well and everything displays ok.</p><p>When I destroy the sub bitmaps all is well for video and memory bitmaps, but when I call destroy_bitmap on the first sub bitmap where the master is of type System Bitmap, the program crashes. </p><p>All the pointers are correct as they both display ok and video/memory works fine. My log shows all is well too:</p><p>New video bitmap is 0x3d9de0<br />Bitmap is sub bitmap of master 0x3d9de0 and created image is 0x3dc138<br />Sub bitmap destroyed 0x3dc138<br />sheet_grid.bmp:0x3d9de0 destroyed</p><p>This is the output for video and memory bitmaps, but when I use system bitmaps it crashes on the first destroy.</p><p>Anyone got a clue as to why?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Neil Walker)</author>
		<pubDate>Tue, 06 Dec 2005 00:39:02 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Compile with debug support, and use gdb to create a backtrace. Post it here to see if there is an error.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (ReyBrujo)</author>
		<pubDate>Tue, 06 Dec 2005 02:14:32 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Do you first...
</p><ul><li><p>Destroy the parent?</p></li></ul><p>&lt;/li&gt;<br />Those are my only guesses until you do what Rey says.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Gideon Weems)</author>
		<pubDate>Tue, 06 Dec 2005 02:23:25 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>This might be of little help.  You can use:</p><p><span class="source-code"><span class="k1">int</span> <a href="http://www.allegro.cc/manual/is_system_bitmap" target="_blank"><span class="a">is_system_bitmap</span></a><span class="k2">(</span><a href="http://www.allegro.cc/manual/BITMAP" target="_blank"><span class="a">BITMAP</span></a> <span class="k3">*</span>bmp<span class="k2">)</span><span class="k2">;</span></span></p><p>to see if the sub_bitmap is a sub of the system bitmap you&#39;ve created.  I&#39;d be curious as to whether the sub_bitmap was &quot;subbing&quot; correctly.  It most likely is.</p><p>I&#39;ve had a problem somewhat like this before, but can&#39;t remember what it was.  When I get home, I&#39;ll look to see if I can find the old problem.  <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Onewing)</author>
		<pubDate>Tue, 06 Dec 2005 02:43:29 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Can you post a small sample programme that duplicates the problem?<br />Not that I can test it myself (system bitmaps are really a Windows thing, as far as Allegro is concerned right now), but others might be able to.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Tue, 06 Dec 2005 03:56:25 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hello,<br />1. How does one create a backtrace? I mainly use MSVC but have mingw installed also.</p><p>2. The parent wasn&#39;t destroyed first and the graphics mode hasn&#39;t changed. As I said it works ok when it is a video or memory bitmap.</p><p>3. Yes, it is a system bitmap, I already checked the output code</p><p>4. Well it&#39;ll be hard to post a little program as it&#39;s part of a very big program <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" /></p><p>Thanks.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Neil Walker)</author>
		<pubDate>Tue, 06 Dec 2005 04:00:30 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
4. Well it&#39;ll be hard to post a little program as it&#39;s part of a very big program
</p></div></div><p>
Sure, but you can write a small programme that creates a system bitmap with child and destroys both of those. Does that reproduce the error? If not, start adding things like video bitmaps along with the system bitmaps and see if that makes the error appear, etc...
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Tue, 06 Dec 2005 04:03:28 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Do you know how to compile with MinGW? Does your program works with MinGW? It also crash?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (ReyBrujo)</author>
		<pubDate>Tue, 06 Dec 2005 04:05:44 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>[edit]I&#39;ve put some outputting to the screen of the image being deleted and I guess I must be doing something wrong as it looks like the image being destroyed is (bizarrely) a different part of the master image. It is doing this for video and system bitmaps but memory ones are ok. I don&#39;t really get this as just before I exit I am ouputting the same images and they display ok!<br />[/edit]</p><p>I&#39;ve ran debug from MSVC and it is crashing where I said, at:  destroy_bitmap(Image). Checking the value of Image (which is a BITMAP pointer) it seems valid to me and it&#39;s address matches that when it was created so it&#39;s pointing  to the same piece of memory:</p><p>-		Image	0x012f0b20 {w=24 h=24 clip=-1 ...}	BITMAP *<br />		w	24	int<br />		h	24	int<br />		clip	-1	int<br />		cl	0	int<br />		cr	24	int<br />		ct	0	int<br />		cb	24	int<br />+		vtable	0x100eaa60 {color_depth=32 mask_color=16711935 unwrite_bank=0x1009524c ...}	GFX_VTABLE *<br />		write_bank	0x10095230	void *<br />		read_bank	0x10095230	void *<br />		dat	0x00000000	void *<br />		id	1610612737	unsigned long<br />		extra	0x012f0068	void *<br />		x_ofs	1	int<br />		y_ofs	47	int<br />		seg	35	int<br />		line	0x012f0b60	unsigned char * [0]</p><p>I&#39;ve ran a trace on the code and the call stack is roughly what I would expect, is it of any use?</p><p> 	alld42.dll!10097efd() 	<br /> 	[Frames below may be incorrect and/or missing, no symbols loaded for alld42.dll]	<br /> 	alld42.dll!100986d3() 	<br /> 	alld42.dll!10038f93() 	<br />&gt;	anim_without_d.exe!AnimationLibraryFrame::~AnimationLibraryFrame()  Line 840 + 0xf bytes	C++<br /> 	anim_without_d.exe!AnimationLibraryFrame::`scalar deleting destructor&#39;()  + 0x2b bytes	C++<br /> 	anim_without_d.exe!AnimationLibraryFrames::~AnimationLibraryFrames()  Line 922 + 0x35 bytes	C++<br /> 	anim_without_d.exe!AnimationLibraryFrames::`scalar deleting destructor&#39;()  + 0x2b bytes	C++<br /> 	anim_without_d.exe!AnimationLibrary::DestroyAll()  Line 1015 + 0x33 bytes	C++<br /> 	anim_without_d.exe!AnimationLibrary::~AnimationLibrary()  Line 1008	C++<br /> 	anim_without_d.exe!AnimationLibrary::`scalar deleting destructor&#39;()  + 0x2b bytes	C++<br /> 	anim_without_d.exe!_mangled_main()  Line 224 + 0x2d bytes	C++<br /> 	alld42.dll!100a8950() 	<br /> 	anim_without_d.exe!WinMain(void * hInst=0x00400000, void * hPrev=0x00000000, char * Cmd=0x001423f6, int nShow=1)  Line 234 + 0x3b bytes	C++<br /> 	anim_without_d.exe!__tmainCRTStartup()  Line 315 + 0x35 bytes	C<br /> 	anim_without_d.exe!WinMainCRTStartup()  Line 187	C<br /> 	kernel32.dll!7c816d4f() 	<br /> 	kernel32.dll!7c8399f3()
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Neil Walker)</author>
		<pubDate>Tue, 06 Dec 2005 04:08:28 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Wait, are you absolutely sure you are <b>first</b> deleting the subbitmaps before deleting the parent bitmap? As per the documentation:</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
BITMAP *create_sub_bitmap(BITMAP *parent, int x, y, width, height);<br />   Creates a sub-bitmap, ie. a bitmap sharing drawing memory with a<br />   pre-existing bitmap, but possibly with a different size and clipping<br />   settings. When creating a sub-bitmap of the mode-X screen, the x position<br />   must be a multiple of four. The sub-bitmap width and height can extend<br />   beyond the right and bottom edges of the parent (they will be clipped),<br />   but the origin point must lie within the parent region.</p><p>   Returns a pointer to the created sub bitmap, or NULL if the sub bitmap<br />   could not be created. <b>Remember to free the sub bitmap before freeing
   the parent bitmap to avoid memory leaks and potential crashes accessing
   memory which has been freed.</b>
</p></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (ReyBrujo)</author>
		<pubDate>Tue, 06 Dec 2005 08:25:07 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Neil: again, have you tried to reproduce the problem with a small example programme?<br />If it&#39;s an Allegro problem, which is possible if you are indeed doing things correctly as you say you are, that will be nescessary to hunt down and fix the problem. If it isn&#39;t an Allegro problem it can still help you track down the problem.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Tue, 06 Dec 2005 15:22:30 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I think it is my code, and it&#39;s probably so obvious I haven&#39;t spotted it! Anyway here is my quick test code:</p><div class="source-code"><div class="toolbar"></div><div class="inner"><table width="100%"><tbody><tr><td class="number">1</td><td>  map<span class="k3">&lt;</span>string,AnimationLibraryFrames<span class="k3">*</span><span class="k3">&gt;</span><span class="k2">:</span><span class="k2">:</span>iterator AnimationIterator<span class="k2">;</span></td></tr><tr><td class="number">2</td><td>  vector<span class="k3">&lt;</span>AnimationLibraryFrame<span class="k3">*</span><span class="k3">&gt;</span><span class="k2">:</span><span class="k2">:</span>iterator AnimationIterator2<span class="k2">;</span></td></tr><tr><td class="number">3</td><td>&#160;</td></tr><tr><td class="number">4</td><td>    <span class="k1">for</span> <span class="k2">(</span>AnimationIterator <span class="k3">=</span> AnimationFrames.begin<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span> AnimationIterator<span class="k3">!</span><span class="k3">=</span> AnimationFrames.end<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span> AnimationIterator<span class="k3">+</span><span class="k3">+</span><span class="k2">)</span></td></tr><tr><td class="number">5</td><td>  <span class="k2">{</span></td></tr><tr><td class="number">6</td><td>    <span class="k1">for</span> <span class="k2">(</span>AnimationIterator2 <span class="k3">=</span> <span class="k2">(</span>AnimationIterator-&gt;second<span class="k2">)</span><span class="k3">-</span><span class="k3">&gt;</span>FrameItems.begin<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span> AnimationIterator2<span class="k3">!</span><span class="k3">=</span> <span class="k2">(</span>AnimationIterator-&gt;second<span class="k2">)</span><span class="k3">-</span><span class="k3">&gt;</span>FrameItems.end<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span> AnimationIterator2<span class="k3">+</span><span class="k3">+</span><span class="k2">)</span></td></tr><tr><td class="number">7</td><td>    <span class="k2">{</span></td></tr><tr><td class="number">8</td><td>      <span class="k1">if</span><span class="k2">(</span><a href="http://www.allegro.cc/manual/is_sub_bitmap" target="_blank"><span class="a">is_sub_bitmap</span></a><span class="k2">(</span><span class="k2">(</span><span class="k3">*</span>AnimationIterator2<span class="k2">)</span><span class="k3">-</span><span class="k3">&gt;</span>Image<span class="k2">)</span><span class="k2">)</span></td></tr><tr><td class="number">9</td><td>      <span class="k2">{</span></td></tr><tr><td class="number">10</td><td>        clear<span class="k2">(</span><a href="http://www.allegro.cc/manual/screen" target="_blank"><span class="a">screen</span></a><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">11</td><td>        <a href="http://www.allegro.cc/manual/blit" target="_blank"><span class="a">blit</span></a><span class="k2">(</span><span class="k2">(</span><span class="k3">*</span>AnimationIterator2<span class="k2">)</span><span class="k3">-</span><span class="k3">&gt;</span>Image,<a href="http://www.allegro.cc/manual/screen" target="_blank"><span class="a">screen</span></a>,<span class="n">0</span>,<span class="n">0</span>,<span class="n">0</span>,<span class="n">0</span>,<span class="k2">(</span><span class="k3">*</span>AnimationIterator2<span class="k2">)</span><span class="k3">-</span><span class="k3">&gt;</span>Image-&gt;w,<span class="k2">(</span><span class="k3">*</span>AnimationIterator2<span class="k2">)</span><span class="k3">-</span><span class="k3">&gt;</span>Image-&gt;h<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">12</td><td>        textprintf<span class="k2">(</span><a href="http://www.allegro.cc/manual/screen" target="_blank"><span class="a">screen</span></a>,<a href="http://www.allegro.cc/manual/font" target="_blank"><span class="a">font</span></a>,<span class="n">0</span>,<span class="n">50</span>,<a href="http://www.allegro.cc/manual/makecol" target="_blank"><span class="a">makecol</span></a><span class="k2">(</span><span class="n">255</span>,<span class="n">0</span>,<span class="n">0</span><span class="k2">)</span>,<span class="s">"%x"</span>,<span class="k2">(</span><span class="k3">*</span>AnimationIterator2<span class="k2">)</span><span class="k3">-</span><span class="k3">&gt;</span>Image<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">13</td><td>        <a href="http://www.allegro.cc/manual/readkey" target="_blank"><span class="a">readkey</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">14</td><td>        <a href="http://www.allegro.cc/manual/destroy_bitmap" target="_blank"><span class="a">destroy_bitmap</span></a><span class="k2">(</span><span class="k2">(</span><span class="k3">*</span>AnimationIterator2<span class="k2">)</span><span class="k3">-</span><span class="k3">&gt;</span>Image<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">15</td><td>      <span class="k2">}</span></td></tr><tr><td class="number">16</td><td>    <span class="k2">}</span></td></tr><tr><td class="number">17</td><td>  <span class="k2">}</span></td></tr></tbody></table></div></div><p>
Basically Frames is a map containing a vector of FrameItems. Image is a BITMAP* So the loop is simply going through each one and displaying it if it is a sub-bitmap. It displays every graphic ok, so why does it crash on the destroy_bitmap()?</p><p>Thanks.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Neil Walker)</author>
		<pubDate>Wed, 07 Dec 2005 06:00:31 +0000</pubDate>
	</item>
</rss>
