X-Hax / SA-Mod-Manager

A new mod manager for the Sonic Adventure games.
MIT License
45 stars 13 forks source link

Loading Profiles returned null when Selected Profile Index >= 10 #147

Closed tonyrigga closed 1 week ago

tonyrigga commented 4 weeks ago

Describe the bug When creating a new profile for SADX or SA2B using SA MM there seems to be a max limit of 9 profiles. If you have the 9th profile selected and try to create a 10th profile SA MM will give an error and have to close. (Error code at the bottom.) This will only happen while your 9th profile is selected. You can bypass this error by creating a 10th profile while any profile Default, < 9 >is selected. Creating a new profile while selecting your 10th or above also won't produce this error.

To Reproduce Steps to reproduce the behavior:

  1. Go to SA MM Manager Config tab
  2. Change your selected profile to the 9th one you've created. (Or create 9 first if you haven't already.)
  3. Click on the book icon again, this will give you the error

Expected behavior I expected to create a 10th profile, but instead I was given an error. This happens consistently when following the reproduction instructions.

Desktop (please complete the following information):

Additional context Error Code:

SAMM Information:
    Manager Version: 1.2.9
    Current Game: Sonic Adventure DX
    Game Directory: H:\SteamLibrary\steamapps\common\Sonic Adventure DX
    Manager Location: H:\SteamLibrary\steamapps\common\Sonic Adventure DX\
    Running as Admin: False
    Mod Loader Version (Hash): 360b98fdfa212055bd2aaa2a068d4f5b6e72149b
Exception Information:
    Type: NullReferenceException
    Exception: Object reference not set to an instance of an object.
    Source: SAModManager
    In Function: Void ModProfile_Loaded(System.Object, System.Windows.RoutedEventArgs)
    StackTrace:    at SAModManager.Profile.ProfileDialog.ModProfile_Loaded(Object sender, RoutedEventArgs e)
       at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
       at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
       at System.Windows.BroadcastEventHelper.BroadcastEvent(DependencyObject root, RoutedEvent routedEvent)
       at System.Windows.BroadcastEventHelper.BroadcastLoadedEvent(Object root)
       at System.Windows.Media.MediaContext.FireLoadedPendingCallbacks()
       at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
       at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
       at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
       at System.Windows.Media.MediaContext.Resize(ICompositionTarget resizedCompositionTarget)
       at System.Windows.Interop.HwndTarget.OnResize()
       at System.Windows.Interop.HwndTarget.HandleMessage(WindowMessage msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Interop.HwndSource.HwndTargetFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
       at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
       at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
       at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
       at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
       at MS.Win32.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
       at MS.Win32.HwndSubclass.DefWndProcWrapper(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
       at MS.Win32.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
       at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
ItsEasyActually commented 4 weeks ago

I've tested this and it's working fine (made 16 profiles, it opens fine). We didn't implement arbitrary limitations like this, so it's not a "limit" issue.

Can you check in your SAManager's Profiles directories (they're in the Users/[username]/Local/SAManager/ directory, SADX and SA2 folders respectively).

My guess is either one of the Profiles.json files didn't save correctly, or there was a failure in loading one of the profiles. If you can provide the contents of whichever Profiles.json file is the one causing the error, that would be helpful. Another thing to check is that all of the expected profiles are not only in the list, but their corresponding files are inside the folder.

tonyrigga commented 4 weeks ago

I can certainly take a look. I will do that tomorrow.

To clarify, it's not really a limit as I too have made more than 9 profiles. (Idk if you read it before or after I made my edit, but I clarify more.) Every time I make 9 profiles, delete them, then remake them, it gives me that error. ONLY when trying to add a new profile WHILE the 9th one is currently selected.

On Thu, May 30, 2024 at 5:17 PM ItsEasyActually @.***> wrote:

I've tested this and it's working fine (made 16 profiles, it opens fine). We didn't implement arbitrary limitations like this, so it's not a "limit" issue.

Can you check in your SAManager's Profiles directories (they're in the Users/[username]/Local/SAManager/ directory, SADX and SA2 folders respectively).

My guess is either one of the Profiles.json files didn't save correctly, or there was a failure in loading one of the profiles. If you can provide the contents of whichever Profiles.json file is the one causing the error, that would be helpful. Another thing to check is that all of the expected profiles are not only in the list, but their corresponding files are inside the folder.

— Reply to this email directly, view it on GitHub https://github.com/X-Hax/SA-Mod-Manager/issues/147#issuecomment-2140878885, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARW6CMA6MJ4FQNHFJHNGTM3ZE6JN3AVCNFSM6AAAAABIRR7ZHCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNBQHA3TQOBYGU . You are receiving this because you authored the thread.Message ID: @.***>

ItsEasyActually commented 4 weeks ago

While I couldn't reproduce it with the ninth selected, your addendum here was enough for me to induce the crash. It was half framework related, half not accounting for giving enough time for everything to load. This has been fixed in 50cc8eb and will be part of the next update.