mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-12 18:27:24 +01:00
Fix crash on Delete Mod Button with no mod selected or already deleted mod.
This commit is contained in:
parent
fc2a18e5e7
commit
374b652f0d
2 changed files with 19 additions and 5 deletions
|
|
@ -2,6 +2,7 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Dalamud.Plugin;
|
||||
using Penumbra.Models;
|
||||
|
||||
namespace Penumbra.Mods
|
||||
|
|
@ -245,8 +246,18 @@ namespace Penumbra.Mods
|
|||
}
|
||||
|
||||
public void DeleteMod( ResourceMod mod )
|
||||
{
|
||||
Directory.Delete( mod.ModBasePath.FullName, true );
|
||||
{
|
||||
if (mod?.ModBasePath?.Exists ?? false)
|
||||
{
|
||||
try
|
||||
{
|
||||
Directory.Delete(mod.ModBasePath.FullName, true);
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
PluginLog.Error($"Could not delete the mod {mod.ModBasePath.Name}:\n{e}");
|
||||
}
|
||||
}
|
||||
DiscoverMods();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -119,8 +119,10 @@ namespace Penumbra.UI
|
|||
|
||||
void DrawDeleteModal()
|
||||
{
|
||||
if( _deleteIndex != null )
|
||||
ImGui.OpenPopup( DialogDeleteMod );
|
||||
if( _deleteIndex == null )
|
||||
return;
|
||||
|
||||
ImGui.OpenPopup( DialogDeleteMod );
|
||||
|
||||
var ret = ImGui.BeginPopupModal( DialogDeleteMod );
|
||||
if( !ret )
|
||||
|
|
@ -129,7 +131,8 @@ namespace Penumbra.UI
|
|||
if( _mod?.Mod == null )
|
||||
{
|
||||
ImGui.CloseCurrentPopup();
|
||||
ImGui.EndPopup();
|
||||
ImGui.EndPopup();
|
||||
return;
|
||||
}
|
||||
|
||||
ImGui.Text( "Are you sure you want to delete the following mod:" );
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue