From 34dd2812f6b8026f39a733409b092edb861cbbd1 Mon Sep 17 00:00:00 2001 From: zeromus Date: Mon, 11 Jun 2012 04:20:13 +0000 Subject: [PATCH] fix lua memory leak (maybe affected today, but the leak is from may 6) and revert some virtuallistview changes which break more things than they fix. it seems .net's listview just happens to blow up internally constantly when its in virtual mode and recover from the exceptions. --- BizHawk.MultiClient/tools/LuaConsole.cs | 8 ++-- BizHawk.Util/VirtualListView.cs | 51 ++++++++++++++++++++----- 2 files changed, 46 insertions(+), 13 deletions(-) diff --git a/BizHawk.MultiClient/tools/LuaConsole.cs b/BizHawk.MultiClient/tools/LuaConsole.cs index 186684bcfc..f472086379 100644 --- a/BizHawk.MultiClient/tools/LuaConsole.cs +++ b/BizHawk.MultiClient/tools/LuaConsole.cs @@ -844,9 +844,11 @@ namespace BizHawk.MultiClient if (s.FrameWaiting && !includeFrameWaiters) prohibit = true; - if (prohibit) continue; - var result = LuaImp.ResumeScript(s.Thread); - s.FrameWaiting = result.WaitForFrame; + if (!prohibit) + { + var result = LuaImp.ResumeScript(s.Thread); + s.FrameWaiting = result.WaitForFrame; + } } LuaImp.gui_drawFinishEmu(); } diff --git a/BizHawk.Util/VirtualListView.cs b/BizHawk.Util/VirtualListView.cs index 486cf0aadd..9cdbb42481 100644 --- a/BizHawk.Util/VirtualListView.cs +++ b/BizHawk.Util/VirtualListView.cs @@ -23,6 +23,19 @@ namespace BizHawk public int code; } + [StructLayout(LayoutKind.Sequential)] + internal struct NMITEMACTIVATE { + NMHDR hdr; + int iItem; + int iSubItem; + uint uNewState; + uint uOldState; + uint uChanged; + POINT ptAction; + uint lParam; + uint uKeyFlags; + } + [StructLayout(LayoutKind.Sequential)] internal struct RECT { public int left, top, right, bottom; @@ -216,7 +229,9 @@ namespace BizHawk internal enum Notices : int { NM_FIRST = 0, - NM_CUSTOMDRAW = NM_FIRST - 12 + NM_CUSTOMDRAW = NM_FIRST - 12, + NM_CLICK = NM_FIRST - 2, + NM_DBLCLICK = NM_FIRST - 3, } internal enum ListViewNotices : int { @@ -542,6 +557,14 @@ namespace BizHawk OnBeginItemDrag(MouseButtons.Right, ref m); messageProcessed = true; break; + //case (int)Notices.NM_CLICK: + //case (int)Notices.NM_DBLCLICK: + // { + // NMITEMACTIVATE test = (NMITEMACTIVATE)m.GetLParam(typeof(NMITEMACTIVATE)); + // messageProcessed = true; + // break; + // } + default: break; } @@ -559,16 +582,24 @@ namespace BizHawk // if (SelectedIndices.Count > 0 && SelectedIndices[0] >= VirtualListSize) // messageProcessed = true; // break; - //TRY THIS HACK INSTEAD TO FIX THE EXCEPTION - case 0x100C: - { - base.WndProc(ref m); - int num = m.Result.ToInt32(); - messageProcessed = true; - m.Result = new IntPtr(-1); - break; - } + // (( NOPE, THEY ALL BREAK ONE THING OR ANOTHER. WINFORMS LISTVIEW JUST THROWS EXCEPTIONS, WHAT CAN WE DO? )) + //case 0x100C: + // { + // base.WndProc(ref m); + // int num = m.Result.ToInt32(); + // messageProcessed = true; + // m.Result = new IntPtr(-1); + // break; + // } + //case 0x1012: + // { + // base.WndProc(ref m); + // int num = m.Result.ToInt32(); + // messageProcessed = true; + // m.Result = new IntPtr(-1); + // break; + // } case (int)WindowsMessage.WM_ERASEBKGND: if (BlazingFast)