gerrykeys / playnite-mame-utility

Playnite extension for MAME game management
MIT License
7 stars 2 forks source link

using mame.exe and having run at least one option so a cache exists, choosing no on the dialog to reuse the cache produces an error #11

Open joyrider3774 opened 11 months ago

joyrider3774 commented 11 months ago

hello,

When using mame.exe and having run at least one option so a cache exists, choosing no on the dialog to reuse the cache produces an error because the machinetype is not known. The machinetype is only set when cached items equals zero however the machinetype is also used when having pressed no on that dialog, so the machinetype is still unknown in that cases and produces the error.

See here machine type is set to unknown: https://github.com/gerrykeys/playnite-mame-utility/blob/main/src/Services/Engine/Platforms/MachinesService.cs#L59 See here machine type is only set when cached items is zero: https://github.com/gerrykeys/playnite-mame-utility/blob/main/src/Services/Engine/Platforms/MachinesService.cs#L67 However see here machine type is used when we choosen "no" on the dialog: https://github.com/gerrykeys/playnite-mame-utility/blob/main/src/Services/Engine/Platforms/MachinesService.cs#L100

and this causes the error. The solution is to always set machinetype even if cached items is non zero, just in case we answer no to the dialog asking if we want to reuse the cache

06-11 09:36:08.388|ERROR|MainMenu:Main menu extension action failed.
System.NullReferenceException: Object reference not set to an instance of an object.
   at MAMEUtility.Services.Engine.Platforms.MachinesService.getMachines() in C:\github\playnite-mame-utility\src\Services\Engine\Platforms\MachinesService.cs:line 103
   at MAMEUtility.Services.Engine.GameMediaManager.setImageOfSelectedGames(ImageType imageType) in C:\github\playnite-mame-utility\src\Services\Library\GameMediaManager.cs:line 152
   at MAMEUtility.Configuration.MainMenu.<>c.<getPluginMenuItems>b__0_4(MainMenuItemActionArgs args) in C:\github\playnite-mame-utility\src\Configuration\MainMenu.cs:line 43
   at Playnite.DesktopApp.Controls.MainMenu.<>c__DisplayClass17_2.<AddExtensionItems>b__1(Object _, RoutedEventArgs __) in C:\projects\playnite\source\Playnite.DesktopApp\Controls\Menus\MainMenu.cs:line 379
06-11 09:37:03.515|ERROR|MainMenu:Main menu extension action failed.
System.NullReferenceException: Object reference not set to an instance of an object.
   at MAMEUtility.Services.Engine.Platforms.MachinesService.getMachines() in C:\github\playnite-mame-utility\src\Services\Engine\Platforms\MachinesService.cs:line 103
   at MAMEUtility.Services.Engine.GameMediaManager.setImageOfSelectedGames(ImageType imageType) in C:\github\playnite-mame-utility\src\Services\Library\GameMediaManager.cs:line 152
   at MAMEUtility.Configuration.MainMenu.<>c.<getPluginMenuItems>b__0_4(MainMenuItemActionArgs args) in C:\github\playnite-mame-utility\src\Configuration\MainMenu.cs:line 43
   at Playnite.DesktopApp.Controls.MainMenu.<>c__DisplayClass17_2.<AddExtensionItems>b__1(Object _, RoutedEventArgs __) in C:\projects\playnite\source\Playnite.DesktopApp\Controls\Menus\MainMenu.cs:line 379
gerrykeys commented 9 months ago

Thanks for report this issue, i will fix asap