mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-12 10:17:22 +01:00
bugfix: moved validation inside lock
This commit is contained in:
parent
0bf9fdea84
commit
1d7603bb8c
1 changed files with 15 additions and 14 deletions
|
|
@ -201,22 +201,23 @@ public class CollectionStorage : IReadOnlyList<ModCollection>, IDisposable, ISer
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool RemoveCollection(ModCollection collection)
|
public bool RemoveCollection(ModCollection collection)
|
||||||
{
|
{
|
||||||
if (collection.Identity.Index <= ModCollection.Empty.Identity.Index || collection.Identity.Index >= Count)
|
|
||||||
{
|
|
||||||
Penumbra.Messager.NotificationMessage("Can not remove the empty collection.", NotificationType.Error, false);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (collection.Identity.Index == DefaultNamed.Identity.Index)
|
|
||||||
{
|
|
||||||
Penumbra.Messager.NotificationMessage("Can not remove the default collection.", NotificationType.Error, false);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Delete(collection);
|
|
||||||
_saveService.ImmediateDelete(new ModCollectionSave(_modStorage, collection));
|
|
||||||
lock (_collectionsLock)
|
lock (_collectionsLock)
|
||||||
{
|
{
|
||||||
|
if (collection.Identity.Index <= ModCollection.Empty.Identity.Index || collection.Identity.Index >= Count)
|
||||||
|
{
|
||||||
|
Penumbra.Messager.NotificationMessage("Can not remove the empty collection.", NotificationType.Error, false);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (collection.Identity.Index == DefaultNamed.Identity.Index)
|
||||||
|
{
|
||||||
|
Penumbra.Messager.NotificationMessage("Can not remove the default collection.", NotificationType.Error, false);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Delete(collection);
|
||||||
|
_saveService.ImmediateDelete(new ModCollectionSave(_modStorage, collection));
|
||||||
|
|
||||||
_collections.RemoveAt(collection.Identity.Index);
|
_collections.RemoveAt(collection.Identity.Index);
|
||||||
// Update indices.
|
// Update indices.
|
||||||
for (var i = collection.Identity.Index; i < _collections.Count; ++i)
|
for (var i = collection.Identity.Index; i < _collections.Count; ++i)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue