From 6afbe8c92b2ce31187bf5567e38dd7ea3dac0aad Mon Sep 17 00:00:00 2001 From: baldurk Date: Mon, 6 Jul 2015 18:15:49 +0200 Subject: [PATCH] Add exception handling on Clipboard.SetText, fall back to SetDataObject --- renderdocui/Windows/APIInspector.cs | 38 +++++++++++++++++-- renderdocui/Windows/EventBrowser.cs | 19 +++++++++- .../PipelineState/D3D11PipelineStateViewer.cs | 19 +++++++++- .../PipelineState/GLPipelineStateViewer.cs | 19 +++++++++- renderdocui/Windows/TextureViewer.cs | 16 +++++++- 5 files changed, 100 insertions(+), 11 deletions(-) diff --git a/renderdocui/Windows/APIInspector.cs b/renderdocui/Windows/APIInspector.cs index c3f9fd6dd..136d92fb6 100644 --- a/renderdocui/Windows/APIInspector.cs +++ b/renderdocui/Windows/APIInspector.cs @@ -275,8 +275,23 @@ namespace renderdocui.Windows text += string.Format("{0,-5} {1}" + Environment.NewLine, n[0].ToString(), n[1].ToString()); } - if (text.Length > 0) - Clipboard.SetText(text); + try + { + if (text.Length > 0) + Clipboard.SetText(text); + } + catch (System.Exception) + { + try + { + if (text.Length > 0) + Clipboard.SetDataObject(text); + } + catch (System.Exception) + { + // give up! + } + } } } @@ -292,8 +307,23 @@ namespace renderdocui.Windows text += n.ToString() + Environment.NewLine; } - if (text.Length > 0) - Clipboard.SetText(text); + try + { + if (text.Length > 0) + Clipboard.SetText(text); + } + catch (System.Exception) + { + try + { + if (text.Length > 0) + Clipboard.SetDataObject(text); + } + catch (System.Exception) + { + // give up! + } + } } } diff --git a/renderdocui/Windows/EventBrowser.cs b/renderdocui/Windows/EventBrowser.cs index 7819754f9..6f721c0f9 100644 --- a/renderdocui/Windows/EventBrowser.cs +++ b/renderdocui/Windows/EventBrowser.cs @@ -670,8 +670,23 @@ namespace renderdocui.Windows } text += Environment.NewLine; - if (text.Length > 0) - Clipboard.SetText(text); + try + { + if (text.Length > 0) + Clipboard.SetText(text); + } + catch (System.Exception) + { + try + { + if (text.Length > 0) + Clipboard.SetDataObject(text); + } + catch (System.Exception) + { + // give up! + } + } } } } diff --git a/renderdocui/Windows/PipelineState/D3D11PipelineStateViewer.cs b/renderdocui/Windows/PipelineState/D3D11PipelineStateViewer.cs index 957a76a08..01745eea9 100644 --- a/renderdocui/Windows/PipelineState/D3D11PipelineStateViewer.cs +++ b/renderdocui/Windows/PipelineState/D3D11PipelineStateViewer.cs @@ -1694,8 +1694,23 @@ namespace renderdocui.Windows.PipelineState } } - if(text.Length > 0) - Clipboard.SetText(text); + try + { + if (text.Length > 0) + Clipboard.SetText(text); + } + catch (System.Exception) + { + try + { + if (text.Length > 0) + Clipboard.SetDataObject(text); + } + catch (System.Exception) + { + // give up! + } + } } } diff --git a/renderdocui/Windows/PipelineState/GLPipelineStateViewer.cs b/renderdocui/Windows/PipelineState/GLPipelineStateViewer.cs index 33c777d96..810bc8f9a 100644 --- a/renderdocui/Windows/PipelineState/GLPipelineStateViewer.cs +++ b/renderdocui/Windows/PipelineState/GLPipelineStateViewer.cs @@ -1712,8 +1712,23 @@ namespace renderdocui.Windows.PipelineState } } - if (text.Length > 0) - Clipboard.SetText(text); + try + { + if (text.Length > 0) + Clipboard.SetText(text); + } + catch (System.Exception) + { + try + { + if (text.Length > 0) + Clipboard.SetDataObject(text); + } + catch (System.Exception) + { + // give up! + } + } } } diff --git a/renderdocui/Windows/TextureViewer.cs b/renderdocui/Windows/TextureViewer.cs index cd3165865..7774d7489 100644 --- a/renderdocui/Windows/TextureViewer.cs +++ b/renderdocui/Windows/TextureViewer.cs @@ -2293,7 +2293,21 @@ namespace renderdocui.Windows if (e.KeyCode == Keys.C && e.Control) { - Clipboard.SetText(texStatusDim.Text + " | " + statusLabel.Text); + try + { + Clipboard.SetText(texStatusDim.Text + " | " + statusLabel.Text); + } + catch (System.Exception) + { + try + { + Clipboard.SetDataObject(texStatusDim.Text + " | " + statusLabel.Text); + } + catch (System.Exception) + { + // give up! + } + } } if (!m_Core.LogLoaded) return;