Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash after duplicating as new Symbol #471

Open
pixtur opened this issue Sep 25, 2024 · 1 comment
Open

Crash after duplicating as new Symbol #471

pixtur opened this issue Sep 25, 2024 · 1 comment
Labels
bug An issue that should be fixed. main-branch

Comments

@pixtur
Copy link
Collaborator

pixtur commented Sep 25, 2024

Describe the bug
A clear and concise description of what the bug is.

Please complete the following information):

  • OS: Win10
  • Version: 3.10 / main
  • Debug mode / Rider

To Reproduce
Steps to reproduce the behavior:

  1. Create [Modulo]
  2. Right-click -> Symbol -> Duplicate as new Type
  3. Crash:

image

after resume...
image

image

@pixtur pixtur added bug An issue that should be fixed. main-branch labels Sep 25, 2024
@pixtur
Copy link
Collaborator Author

pixtur commented Sep 25, 2024

On release if get the following stacktrace in the crash-reporter:

On noooo, how embarrassing! T3 just crashed
Last backup was saved 1 minutes ago to .t3/backups/
Please consult the Wiki on what to do next.

When this window closes, the current operator will be copied to your clipboard. You can use it to troubleshoot/reproduce the issue.

System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')
   at System.Collections.Generic.List`1.RemoveAt(Int32 index)
   at T3.Core.Operator.Symbol.DestroyInstance(Instance instance, Int32 index) in C:\Users\pixtur\dev\tooll\t3-main\Core\Operator\Symbol.cs:line 113
   at T3.Core.Operator.Symbol.DestroyInstance(Instance instance, Int32 index) in C:\Users\pixtur\dev\tooll\t3-main\Core\Operator\Symbol.cs:line 106
   at T3.Core.Operator.Symbol.DestroyInstance(Instance instance, Int32 index) in C:\Users\pixtur\dev\tooll\t3-main\Core\Operator\Symbol.cs:line 106
   at T3.Core.Operator.Symbol.UpdateInstanceType() in C:\Users\pixtur\dev\tooll\t3-main\Core\Operator\Symbol.TypeUpdating.cs:line 40
   at T3.Core.Model.SymbolPackage.UpdateSymbolInstances(Symbol symbol) in C:\Users\pixtur\dev\tooll\t3-main\Core\Model\SymbolPackage.cs:line 263
   at T3.Core.Model.SymbolPackage.LoadSymbols(Boolean parallel, List`1& newlyRead, List`1& allNewSymbols) in C:\Users\pixtur\dev\tooll\t3-main\Core\Model\SymbolPackage.cs:line 163
   at T3.Editor.Compilation.ProjectSetup.UpdateSymbolPackages(PackageWithReleaseInfo[] packages) in C:\Users\pixtur\dev\tooll\t3-main\Editor\Compilation\ProjectSetup.cs:line 238
   at T3.Editor.Compilation.ProjectSetup.UpdateSymbolPackage[T](T project) in C:\Users\pixtur\dev\tooll\t3-main\Editor\Compilation\ProjectSetup.cs:line 179
   at T3.Editor.UiModel.EditableSymbolProject.TryCompile(String sourceCode, String newSymbolName, Guid newSymbolId, String nameSpace, Symbol& newSymbol, SymbolUi& newSymbolUi) in C:\Users\pixtur\dev\tooll\t3-main\Editor\UiModel\EditableSymbolProject.Recompilation.cs:line 52
   at T3.Editor.Gui.Graph.Modification.Duplicate.DuplicateAsNewType(SymbolUi compositionUi, EditableSymbolProject project, Guid symbolId, String newTypeName, String nameSpace, String description, Vector2 posOnCanvas) in C:\Users\pixtur\dev\tooll\t3-main\Editor\Gui\Graph\Modification\Duplicate.cs:line 51
   at T3.Editor.Gui.Graph.GraphCanvas.DrawGraph(ImDrawListPtr drawList, GraphDrawingFlags drawingFlags, Boolean preventInteractions, Single graphOpacity)
   at T3.Editor.Gui.Graph.GraphWindow.DrawContent() in C:\Users\pixtur\dev\tooll\t3-main\Editor\Gui\Graph\GraphWindow.cs:line 177
   at T3.Editor.Gui.Windows.Window.Draw() in C:\Users\pixtur\dev\tooll\t3-main\Editor\Gui\Windows\Window.cs:line 46
   at T3.Editor.Gui.Windows.Layouts.WindowManager.Draw() in C:\Users\pixtur\dev\tooll\t3-main\Editor\Gui\Windows\Layouts\WindowManager.cs:line 36
   at T3.Editor.Gui.T3Ui.ProcessFrame() in C:\Users\pixtur\dev\tooll\t3-main\Editor\Gui\T3UI.cs:line 122
   at T3.Editor.Gui.WindowsUiContentDrawer.RenderCallback() in C:\Users\pixtur\dev\tooll\t3-main\Editor\Gui\WindowsUiContentDrawer.cs:line 159
   at SharpDX.Windows.RenderLoop.Run(Control form, RenderCallback renderCallback, Boolean useApplicationDoEvents)
   at T3.Editor.App.AppWindow.RunRenderLoop(Action callback) in C:\Users\pixtur\dev\tooll\t3-main\Editor\App\AppWindow.cs:line 111
   at T3.Editor.Program.Main(String[] args) in C:\Users\pixtur\dev\tooll\t3-main\Editor\Program.cs:line 184

Which leads to Symbol.cs -> DestroyInstance()

     private void DestroyInstance(Instance instance, int index = -1)
     {
         var allChildren = instance.ChildInstances.Values.ToArray();
         foreach (var child in allChildren)
         {
             child.Symbol.DestroyInstance(child);
         }
         
         instance.Parent?.ChildInstances.Remove(instance.SymbolChildId);
         instance.Dispose();
         
         index = index == -1 ? _instancesOfSelf.IndexOf(instance) : index;
         _instancesOfSelf.RemoveAt(index);  // <------------
     }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An issue that should be fixed. main-branch
Projects
Status: No status
Development

No branches or pull requests

1 participant