mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-13 12:14:17 +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.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Dalamud.Plugin;
|
||||||
using Penumbra.Models;
|
using Penumbra.Models;
|
||||||
|
|
||||||
namespace Penumbra.Mods
|
namespace Penumbra.Mods
|
||||||
|
|
@ -245,8 +246,18 @@ namespace Penumbra.Mods
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DeleteMod( ResourceMod mod )
|
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();
|
DiscoverMods();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -119,8 +119,10 @@ namespace Penumbra.UI
|
||||||
|
|
||||||
void DrawDeleteModal()
|
void DrawDeleteModal()
|
||||||
{
|
{
|
||||||
if( _deleteIndex != null )
|
if( _deleteIndex == null )
|
||||||
ImGui.OpenPopup( DialogDeleteMod );
|
return;
|
||||||
|
|
||||||
|
ImGui.OpenPopup( DialogDeleteMod );
|
||||||
|
|
||||||
var ret = ImGui.BeginPopupModal( DialogDeleteMod );
|
var ret = ImGui.BeginPopupModal( DialogDeleteMod );
|
||||||
if( !ret )
|
if( !ret )
|
||||||
|
|
@ -129,7 +131,8 @@ namespace Penumbra.UI
|
||||||
if( _mod?.Mod == null )
|
if( _mod?.Mod == null )
|
||||||
{
|
{
|
||||||
ImGui.CloseCurrentPopup();
|
ImGui.CloseCurrentPopup();
|
||||||
ImGui.EndPopup();
|
ImGui.EndPopup();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.Text( "Are you sure you want to delete the following mod:" );
|
ImGui.Text( "Are you sure you want to delete the following mod:" );
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue