<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Direct3D with Display Events does not shut down</title>
		<link>http://www.allegro.cc/forums/view/600837</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Wed, 08 Jul 2009 20:54:39 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>The following code randomly fails to shut down with MSVC 8 and Allegro 4.9.12 (binaries from allegro5.org):
</p><div class="source-code"><div class="toolbar"><span class="button numbers"><b>#</b></span><span class="button select">Select</span><span class="button expand">Expand</span></div><div class="inner"><span class="number">  1</span><span class="p">#include &lt;allegro5/allegro.h&gt;</span>
<span class="number">  2</span><span class="p">#include &lt;allegro5/a5_opengl.h&gt;</span>
<span class="number">  3</span><span class="p">#include &lt;allegro5/a5_direct3d.h&gt;</span>
<span class="number">  4</span>
<span class="number">  5</span><span class="k1">int</span> main<span class="k2">(</span><span class="k2">)</span>
<span class="number">  6</span><span class="k2">{</span>
<span class="number">  7</span>  al_init<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
<span class="number">  8</span>  al_install_keyboard<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
<span class="number">  9</span>
<span class="number"> 10</span>  al_set_new_display_flags<span class="k2">(</span>ALLEGRO_WINDOWED <span class="k3">|</span> ALLEGRO_DIRECT3D<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 11</span>
<span class="number"> 12</span>  ALLEGRO_DISPLAY <span class="k3">*</span>display <span class="k3">=</span> al_create_display<span class="k2">(</span><span class="n">640</span>, <span class="n">480</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 13</span>
<span class="number"> 14</span>  ALLEGRO_EVENT_QUEUE <span class="k3">*</span>queue <span class="k3">=</span> al_create_event_queue<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 15</span>  al_register_event_source<span class="k2">(</span>queue, <span class="k2">(</span>ALLEGRO_EVENT_SOURCE <span class="k3">*</span><span class="k2">)</span>display<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 16</span>
<span class="number"> 17</span>  ALLEGRO_EVENT event<span class="k2">;</span>
<span class="number"> 18</span>  al_wait_for_event<span class="k2">(</span>queue, <span class="k3">&amp;</span>event<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 19</span>
<span class="number"> 20</span>  al_destroy_event_queue<span class="k2">(</span>queue<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 21</span>
<span class="number"> 22</span>  al_destroy_display<span class="k2">(</span>display<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 23</span>
<span class="number"> 24</span>  al_uninstall_system<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 25</span>
<span class="number"> 26</span>  <span class="k1">return</span> <span class="n">0</span><span class="k2">;</span>
<span class="number"> 27</span><span class="k2">}</span>
<span class="number"> 28</span><a href="http://www.allegro.cc/manual/END_OF_MAIN" target="_blank"><span class="a">END_OF_MAIN</span></a><span class="k2">(</span><span class="k2">)</span>
</div></div><p>

Sometimes it shuts down correctly, but when it fails, it appears to never return from the call to <span class="source-code">al_destroy_event_queue<span class="k2">(</span>queue<span class="k2">)</span><span class="k2">;</span></span>. The problem does not seem to exist when using the OpenGL driver or when not attaching display events.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Wed, 08 Jul 2009 00:59:38 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I just ran that program about 15 times and it didn&#39;t hang for me. How often does it hang? What OS? Are you just pressing the close button? I also ran it through Memory Validator and didn&#39;t see any problems or hangs.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Trent Gamblin)</author>
		<pubDate>Wed, 08 Jul 2009 02:47:37 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Windows 7 64-bit. Over 95% of the time it hangs after pressing the close button.</p><p>The window disappears, but the process is still running at 0% CPU usage. If I break out of the debugger, MSVC 8 has a green arrow next to the <span class="source-code">al_destroy_display<span class="k2">(</span><span class="k2">)</span></span> line. If I resume the debugger, then the program terminates successfully.</p><p>Even when running in release mode without a debugger, it hangs.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Wed, 08 Jul 2009 02:58:51 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I will try it on Windows 7 32 bit but I don&#39;t have 64 to try.</p><p>...</p><p>Works fine here. I am not running it from VS however. I compiled it with VS 2008 but I&#39;m running it from cmd.exe. It returns every time. Does it still not work if you run it from cmd.exe or Explorer? Check for whatever.exe in your process list after running it a few times.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Trent Gamblin)</author>
		<pubDate>Wed, 08 Jul 2009 03:01:13 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>It happens outside of VS 2008 as well. I also was able to duplicate it on my Windows 7 64-bit laptop using my own compiled version of Allegro. However, the problem doesn&#39;t occur (as far as I could tell) when running the debug version of Allegro.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Wed, 08 Jul 2009 06:40:30 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I think I was a little overzealous when I went memory leak hunting and I think I made a mistake. Not sure this is your problem but try the attached patch.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Trent Gamblin)</author>
		<pubDate>Wed, 08 Jul 2009 08:10:32 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Still has the same behavior.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Wed, 08 Jul 2009 20:54:39 +0000</pubDate>
	</item>
</rss>
