Avoid deserializing clipboard content in Custom Editor paste checks
This commit is contained in:
@@ -675,20 +675,7 @@ namespace FlaxEditor.CustomEditors
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether can paste value from the system clipboard to the property value container.
|
||||
/// </summary>
|
||||
public bool CanPaste
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
return GetClipboardObject(out _, false);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
public bool CanPaste => !string.IsNullOrEmpty(Clipboard.Text);
|
||||
|
||||
/// <summary>
|
||||
/// Sets the value from the system clipboard.
|
||||
|
||||
@@ -474,32 +474,7 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
}
|
||||
if (layout.Editors.Count != 0)
|
||||
{
|
||||
var sb = Clipboard.Text;
|
||||
if (!string.IsNullOrEmpty(sb))
|
||||
{
|
||||
try
|
||||
{
|
||||
var data = JsonSerializer.Deserialize<string[]>(sb);
|
||||
if (data == null || data.Length != layout.Editors.Count)
|
||||
return false;
|
||||
for (var i = 0; i < layout.Editors.Count; i++)
|
||||
{
|
||||
Clipboard.Text = data[i];
|
||||
if (!layout.Editors[i].CanPaste)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
finally
|
||||
{
|
||||
Clipboard.Text = sb;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return !string.IsNullOrEmpty(Clipboard.Text);
|
||||
}
|
||||
if (layout.Children.Any(x => x is LayoutElementsContainer))
|
||||
{
|
||||
|
||||
@@ -190,15 +190,7 @@ namespace FlaxEditor.Surface
|
||||
if (data == null || data.Length < 2)
|
||||
return false;
|
||||
|
||||
try
|
||||
{
|
||||
var model = JsonConvert.DeserializeObject<DataModel>(data);
|
||||
return model?.Nodes != null && model.Nodes.Length != 0;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -215,7 +207,15 @@ namespace FlaxEditor.Surface
|
||||
try
|
||||
{
|
||||
// Load Mr Json
|
||||
var model = FlaxEngine.Json.JsonSerializer.Deserialize<DataModel>(data);
|
||||
DataModel model;
|
||||
try
|
||||
{
|
||||
model = FlaxEngine.Json.JsonSerializer.Deserialize<DataModel>(data);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (model.Nodes == null)
|
||||
model.Nodes = new DataModelNode[0];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user