Browse Source

Fixed SD2-1641 - Random crash in AvalonEdit when copying to the clipboard

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@5455 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Daniel Grunwald 16 years ago
parent
commit
2b007b4365
  1. 20
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/EditingCommandHandler.cs

20
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/EditingCommandHandler.cs

@ -11,6 +11,7 @@ using System.Diagnostics; @@ -11,6 +11,7 @@ using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows;
using System.Windows.Documents;
@ -306,7 +307,15 @@ namespace ICSharpCode.AvalonEdit.Editing @@ -306,7 +307,15 @@ namespace ICSharpCode.AvalonEdit.Editing
static void CopySelectedText(TextArea textArea)
{
Clipboard.SetDataObject(textArea.Selection.CreateDataObject(textArea), true);
var data = textArea.Selection.CreateDataObject(textArea);
try {
Clipboard.SetDataObject(data, true);
} catch (ExternalException) {
// Apparently this exception sometimes happens randomly.
// The MS controls just ignore it, so we'll do the same.
return;
}
string text = textArea.Selection.GetText(textArea.Document);
text = NewLineFinder.NormalizeNewLines(text, Environment.NewLine);
@ -332,8 +341,13 @@ namespace ICSharpCode.AvalonEdit.Editing @@ -332,8 +341,13 @@ namespace ICSharpCode.AvalonEdit.Editing
lineSelected.WriteByte(1);
data.SetData(LineSelectedType, lineSelected, false);
Clipboard.SetDataObject(data, true);
try {
Clipboard.SetDataObject(data, true);
} catch (ExternalException) {
// Apparently this exception sometimes happens randomly.
// The MS controls just ignore it, so we'll do the same.
return;
}
textArea.OnTextCopied(new TextEventArgs(text));
}

Loading…
Cancel
Save