From b255f5bc3604dc3e5c80a89464c997fd918b4c6b Mon Sep 17 00:00:00 2001 From: baldurk Date: Wed, 12 Nov 2014 23:38:40 +0000 Subject: [PATCH] Protect against ArgumentException in Timeline Bar paint * Crash report was submitted indicating a crash here, which is either memory issues or momentarily crazy-large window. We can catch the exception and just clear to black. --- renderdocui/Windows/TimelineBar.cs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/renderdocui/Windows/TimelineBar.cs b/renderdocui/Windows/TimelineBar.cs index 095edba25..0ff472cd2 100644 --- a/renderdocui/Windows/TimelineBar.cs +++ b/renderdocui/Windows/TimelineBar.cs @@ -708,6 +708,8 @@ namespace renderdocui.Windows private PointF m_CurrentMarker = new PointF(-1, -1); + private bool m_FailedPaint = false; + private void panel_Paint(object sender, PaintEventArgs e) { if(ClientRectangle.Width <= 0 || ClientRectangle.Height <= 0) @@ -715,7 +717,24 @@ namespace renderdocui.Windows Cursor = Cursors.Arrow; - var bmp = new Bitmap(ClientRectangle.Width, ClientRectangle.Height); + Bitmap bmp = null; + + try + { + bmp = new Bitmap(ClientRectangle.Width, ClientRectangle.Height); + } + catch (System.ArgumentException) + { + // out of memory or huge bitmap. Clear to black rather than crashing + e.Graphics.Clear(Color.Black); + + if(!m_FailedPaint) + { + renderdoc.StaticExports.LogText("Failed to paint TimelineBar - System.ArgumentException"); + m_FailedPaint = true; + } + return; + } var g = Graphics.FromImage(bmp);