Browse Source

Avoid NullReferenceException when DataObject.GetData returns null.

4.0
Daniel Grunwald 15 years ago
parent
commit
62ce690fd1
  1. 5
      src/Main/Base/Project/Src/Gui/Workbench/WpfWorkbench.cs

5
src/Main/Base/Project/Src/Gui/Workbench/WpfWorkbench.cs

@ -627,12 +627,14 @@ namespace ICSharpCode.SharpDevelop.Gui
try { try {
if (data != null && data.GetDataPresent(DataFormats.FileDrop)) { if (data != null && data.GetDataPresent(DataFormats.FileDrop)) {
string[] files = (string[])data.GetData(DataFormats.FileDrop); string[] files = (string[])data.GetData(DataFormats.FileDrop);
if (files != null) {
foreach (string file in files) { foreach (string file in files) {
if (File.Exists(file)) { if (File.Exists(file)) {
return DragDropEffects.Link; return DragDropEffects.Link;
} }
} }
} }
}
} catch (COMException) { } catch (COMException) {
// Ignore errors getting the data (e.g. happens when dragging attachments out of Thunderbird) // Ignore errors getting the data (e.g. happens when dragging attachments out of Thunderbird)
} }
@ -646,7 +648,8 @@ namespace ICSharpCode.SharpDevelop.Gui
if (!e.Handled && e.Data != null && e.Data.GetDataPresent(DataFormats.FileDrop)) { if (!e.Handled && e.Data != null && e.Data.GetDataPresent(DataFormats.FileDrop)) {
e.Handled = true; e.Handled = true;
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
if (files == null)
return;
foreach (string file in files) { foreach (string file in files) {
if (File.Exists(file)) { if (File.Exists(file)) {
Project.IProjectLoader loader = Project.ProjectService.GetProjectLoader(file); Project.IProjectLoader loader = Project.ProjectService.GetProjectLoader(file);

Loading…
Cancel
Save