Prevent crashes under certain conditions

This commit is contained in:
Michael Becker 2015-05-05 07:56:12 -04:00
parent 6fef5ab680
commit f6b898c1b6

View File

@ -766,8 +766,9 @@ namespace UniversalEditor.UserInterface.WindowsForms.Editors
{
if (lv.SelectedItems.Count == 0)
{
string fileName = ObjectModel.Accessor.GetFileName();
if (System.IO.File.Exists(fileName))
string fileName = null;
if (ObjectModel.Accessor != null) fileName = ObjectModel.Accessor.GetFileName();
if (!String.IsNullOrEmpty(fileName) && System.IO.File.Exists(fileName))
{
File file = new File();
file.Name = fileName;
@ -792,6 +793,10 @@ namespace UniversalEditor.UserInterface.WindowsForms.Editors
if (file != null)
{
Dialogs.FileSystem.FilePropertiesDialog dlg = new Dialogs.FileSystem.FilePropertiesDialog();
if (ObjectModel.Accessor != null)
{
dlg.ParentFileName = ObjectModel.Accessor.GetFileName();
}
dlg.SelectedObjects.Add(file);
if (dlg.ShowDialog() == DialogResult.OK)