Fixed issues found by PVS-Studio
This commit is contained in:
@@ -123,10 +123,10 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
_linkButton.Clicked += ToggleLink;
|
||||
ToggleEnabled();
|
||||
SetLinkStyle();
|
||||
var textSize = FlaxEngine.GUI.Style.Current.FontMedium.MeasureText(LinkedLabel.Text.Value);
|
||||
_linkButton.LocalX += textSize.X + 10;
|
||||
if (LinkedLabel != null)
|
||||
{
|
||||
var textSize = FlaxEngine.GUI.Style.Current.FontMedium.MeasureText(LinkedLabel.Text.Value);
|
||||
_linkButton.LocalX += textSize.X + 10;
|
||||
LinkedLabel.SetupContextMenu += (label, menu, editor) =>
|
||||
{
|
||||
menu.AddSeparator();
|
||||
|
||||
@@ -50,7 +50,6 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (_element == null)
|
||||
{
|
||||
// Use int value editor
|
||||
var element = layout.IntegerValue();
|
||||
|
||||
@@ -337,14 +337,12 @@ namespace FlaxEditor.GUI.ContextMenu
|
||||
/// <summary>
|
||||
/// Adds the separator.
|
||||
/// </summary>
|
||||
/// <returns>Created context menu item control.</returns>
|
||||
public ContextMenuSeparator AddSeparator()
|
||||
public void AddSeparator()
|
||||
{
|
||||
var item = new ContextMenuSeparator(this)
|
||||
{
|
||||
Parent = _panel
|
||||
};
|
||||
return item;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -130,9 +130,9 @@ namespace FlaxEditor.GUI.Timeline
|
||||
public override void OnPlay()
|
||||
{
|
||||
var time = CurrentTime;
|
||||
_preview.Play();
|
||||
if (_preview != null)
|
||||
{
|
||||
_preview.Play();
|
||||
Editor.Internal_SetAnimationTime(Object.GetUnmanagedPtr(_preview.PreviewActor), time);
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,8 @@ namespace FlaxEditor.GUI.Timeline.Undo
|
||||
|
||||
private void Set(byte[] data)
|
||||
{
|
||||
if (_timeline == null)
|
||||
return;
|
||||
var track = _timeline.FindTrack(_name);
|
||||
using (var memory = new MemoryStream(data))
|
||||
using (var stream = new BinaryReader(memory))
|
||||
@@ -42,11 +44,8 @@ namespace FlaxEditor.GUI.Timeline.Undo
|
||||
track.Flags = (TrackFlags)stream.ReadByte();
|
||||
track.Archetype.Load(Timeline.FormatVersion, track, stream);
|
||||
}
|
||||
if (_timeline != null)
|
||||
{
|
||||
_timeline.ArrangeTracks();
|
||||
_timeline.MarkAsEdited();
|
||||
}
|
||||
_timeline.ArrangeTracks();
|
||||
_timeline.MarkAsEdited();
|
||||
track.OnUndo();
|
||||
}
|
||||
|
||||
|
||||
@@ -57,8 +57,9 @@ namespace FlaxEditor.States
|
||||
{
|
||||
// Generate project files when Cache is missing or was cleared previously
|
||||
var projectFolderPath = Editor.GameProject?.ProjectFolderPath;
|
||||
if (!Directory.Exists(Path.Combine(projectFolderPath, "Cache", "Intermediate")) ||
|
||||
!Directory.Exists(Path.Combine(projectFolderPath, "Cache", "Projects")))
|
||||
if (!string.IsNullOrEmpty(projectFolderPath) &&
|
||||
(!Directory.Exists(Path.Combine(projectFolderPath, "Cache", "Intermediate")) ||
|
||||
!Directory.Exists(Path.Combine(projectFolderPath, "Cache", "Projects"))))
|
||||
{
|
||||
var customArgs = Editor.CodeEditing.SelectedEditor?.GenerateProjectCustomArgs;
|
||||
ScriptsBuilder.GenerateProject(customArgs);
|
||||
|
||||
@@ -976,10 +976,12 @@ namespace FlaxEditor.Surface
|
||||
else
|
||||
Array.Copy(values, Values, values.Length);
|
||||
OnValuesChanged();
|
||||
Surface.MarkAsEdited(graphEdited);
|
||||
|
||||
if (Surface != null)
|
||||
{
|
||||
Surface.MarkAsEdited(graphEdited);
|
||||
Surface.AddBatchedUndoAction(new EditNodeValuesAction(this, before, graphEdited));
|
||||
}
|
||||
|
||||
_isDuringValuesEditing = false;
|
||||
}
|
||||
|
||||
@@ -62,7 +62,8 @@ namespace FlaxEditor.Surface
|
||||
/// <remarks>
|
||||
/// The method calls the <see cref="ISurfaceContext.SurfaceData"/> setter to assign the result bytes. Sets null value if failed.
|
||||
/// </remarks>
|
||||
public virtual void Save()
|
||||
/// <returns>True if failed, otherwise false.</returns>
|
||||
public virtual bool Save()
|
||||
{
|
||||
var wasEdited = IsEdited;
|
||||
|
||||
@@ -71,19 +72,16 @@ namespace FlaxEditor.Surface
|
||||
_context.CachedSurfaceMeta.Scale = ViewScale;
|
||||
|
||||
// Save context (and every modified child context)
|
||||
bool failed = RootContext.Save();
|
||||
|
||||
if (failed)
|
||||
{
|
||||
// Error
|
||||
return;
|
||||
}
|
||||
if (RootContext.Save())
|
||||
return true;
|
||||
|
||||
// Clear flag
|
||||
if (wasEdited)
|
||||
{
|
||||
Owner.OnSurfaceEditedChanged();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -430,8 +430,7 @@ namespace FlaxEditor.Windows.Assets
|
||||
|
||||
private bool SaveSurface()
|
||||
{
|
||||
_surface.Save();
|
||||
return false;
|
||||
return _surface.Save();
|
||||
}
|
||||
|
||||
private void SetCanEdit(bool canEdit)
|
||||
|
||||
@@ -1202,7 +1202,8 @@ namespace FlaxEditor.Windows.Assets
|
||||
|
||||
private bool SaveSurface()
|
||||
{
|
||||
_surface.Save();
|
||||
if (_surface.Save())
|
||||
return true;
|
||||
|
||||
// Reselect actors to prevent issues after Visual Script properties were modified
|
||||
Editor.Windows.PropertiesWin.Presenter.BuildLayoutOnUpdate();
|
||||
|
||||
@@ -750,7 +750,7 @@ namespace FlaxEngine.GUI
|
||||
{
|
||||
if (base.IsTouchOver)
|
||||
return true;
|
||||
for (int i = 0; i < _children.Count && _children.Count > 0; i++)
|
||||
for (int i = 0; i < _children.Count; i++)
|
||||
{
|
||||
if (_children[i].IsTouchOver)
|
||||
return true;
|
||||
@@ -960,7 +960,7 @@ namespace FlaxEngine.GUI
|
||||
public override void OnMouseLeave()
|
||||
{
|
||||
// Check all children collisions with mouse and fire events for them
|
||||
for (int i = 0; i < _children.Count && _children.Count > 0; i++)
|
||||
for (int i = 0; i < _children.Count; i++)
|
||||
{
|
||||
var child = _children[i];
|
||||
if (child.Visible && child.Enabled && child.IsMouseOver)
|
||||
@@ -1063,7 +1063,7 @@ namespace FlaxEngine.GUI
|
||||
if (base.IsTouchPointerOver(pointerId))
|
||||
return true;
|
||||
|
||||
for (int i = 0; i < _children.Count && _children.Count > 0; i++)
|
||||
for (int i = 0; i < _children.Count; i++)
|
||||
{
|
||||
if (_children[i].IsTouchPointerOver(pointerId))
|
||||
return true;
|
||||
@@ -1168,7 +1168,7 @@ namespace FlaxEngine.GUI
|
||||
/// <inheritdoc />
|
||||
public override void OnTouchLeave(int pointerId)
|
||||
{
|
||||
for (int i = 0; i < _children.Count && _children.Count > 0; i++)
|
||||
for (int i = 0; i < _children.Count; i++)
|
||||
{
|
||||
var child = _children[i];
|
||||
if (child.Visible && child.Enabled && child.IsTouchPointerOver(pointerId))
|
||||
@@ -1183,7 +1183,7 @@ namespace FlaxEngine.GUI
|
||||
/// <inheritdoc />
|
||||
public override bool OnCharInput(char c)
|
||||
{
|
||||
for (int i = 0; i < _children.Count && _children.Count > 0; i++)
|
||||
for (int i = 0; i < _children.Count; i++)
|
||||
{
|
||||
var child = _children[i];
|
||||
if (child.Enabled && child.ContainsFocus)
|
||||
@@ -1197,7 +1197,7 @@ namespace FlaxEngine.GUI
|
||||
/// <inheritdoc />
|
||||
public override bool OnKeyDown(KeyboardKeys key)
|
||||
{
|
||||
for (int i = 0; i < _children.Count && _children.Count > 0; i++)
|
||||
for (int i = 0; i < _children.Count; i++)
|
||||
{
|
||||
var child = _children[i];
|
||||
if (child.Enabled && child.ContainsFocus)
|
||||
@@ -1211,7 +1211,7 @@ namespace FlaxEngine.GUI
|
||||
/// <inheritdoc />
|
||||
public override void OnKeyUp(KeyboardKeys key)
|
||||
{
|
||||
for (int i = 0; i < _children.Count && _children.Count > 0; i++)
|
||||
for (int i = 0; i < _children.Count; i++)
|
||||
{
|
||||
var child = _children[i];
|
||||
if (child.Enabled && child.ContainsFocus)
|
||||
@@ -1294,7 +1294,7 @@ namespace FlaxEngine.GUI
|
||||
base.OnDragLeave();
|
||||
|
||||
// Check all children collisions with mouse and fire events for them
|
||||
for (int i = 0; i < _children.Count && _children.Count > 0; i++)
|
||||
for (int i = 0; i < _children.Count; i++)
|
||||
{
|
||||
var child = _children[i];
|
||||
if (child.IsDragOver)
|
||||
|
||||
Reference in New Issue
Block a user