mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Fix concurrent exception when update group
This commit is contained in:
@@ -799,20 +799,19 @@ class GroupActivity : LockingActivity(),
|
|||||||
GroupEditDialogFragment.EditGroupDialogAction.UPDATE -> {
|
GroupEditDialogFragment.EditGroupDialogAction.UPDATE -> {
|
||||||
// If update add new elements
|
// If update add new elements
|
||||||
mOldGroupToUpdate?.let { oldGroupToUpdate ->
|
mOldGroupToUpdate?.let { oldGroupToUpdate ->
|
||||||
GroupVersioned(oldGroupToUpdate).let { updateGroup ->
|
val updateGroup = GroupVersioned(oldGroupToUpdate).let { updateGroup ->
|
||||||
updateGroup.apply {
|
updateGroup.apply {
|
||||||
// WARNING remove parent and children to keep memory
|
// WARNING remove parent and children to keep memory
|
||||||
removeParent()
|
removeParent()
|
||||||
removeChildren() // TODO concurrent exception
|
removeChildren()
|
||||||
|
|
||||||
title = name
|
title = name
|
||||||
this.icon = icon // TODO custom icon
|
this.icon = icon // TODO custom icon
|
||||||
}
|
}
|
||||||
|
|
||||||
// If group updated save it in the database
|
|
||||||
progressDialogThread?.startDatabaseUpdateGroup(
|
|
||||||
oldGroupToUpdate, updateGroup, !mReadOnly)
|
|
||||||
}
|
}
|
||||||
|
// If group updated save it in the database
|
||||||
|
progressDialogThread?.startDatabaseUpdateGroup(
|
||||||
|
oldGroupToUpdate, updateGroup, !mReadOnly)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else -> {}
|
else -> {}
|
||||||
|
|||||||
@@ -130,22 +130,6 @@ class GroupVersioned : NodeVersioned, PwGroupInterface<GroupVersioned, EntryVers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun removeChildren() {
|
|
||||||
pwGroupV3?.getChildEntries()?.forEach { entryToRemove ->
|
|
||||||
pwGroupV3?.removeChildEntry(entryToRemove)
|
|
||||||
}
|
|
||||||
pwGroupV3?.getChildGroups()?.forEach { groupToRemove ->
|
|
||||||
pwGroupV3?.removeChildGroup(groupToRemove)
|
|
||||||
}
|
|
||||||
|
|
||||||
pwGroupV4?.getChildEntries()?.forEach { entryToRemove ->
|
|
||||||
pwGroupV4?.removeChildEntry(entryToRemove)
|
|
||||||
}
|
|
||||||
pwGroupV4?.getChildGroups()?.forEach { groupToRemove ->
|
|
||||||
pwGroupV4?.removeChildGroup(groupToRemove)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun touch(modified: Boolean, touchParents: Boolean) {
|
override fun touch(modified: Boolean, touchParents: Boolean) {
|
||||||
pwGroupV3?.touch(modified, touchParents)
|
pwGroupV3?.touch(modified, touchParents)
|
||||||
pwGroupV4?.touch(modified, touchParents)
|
pwGroupV4?.touch(modified, touchParents)
|
||||||
@@ -287,6 +271,11 @@ class GroupVersioned : NodeVersioned, PwGroupInterface<GroupVersioned, EntryVers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun removeChildren() {
|
||||||
|
pwGroupV3?.removeChildren()
|
||||||
|
pwGroupV4?.removeChildren()
|
||||||
|
}
|
||||||
|
|
||||||
override fun allowAddEntryIfIsRoot(): Boolean {
|
override fun allowAddEntryIfIsRoot(): Boolean {
|
||||||
return pwGroupV3?.allowAddEntryIfIsRoot() ?: pwGroupV4?.allowAddEntryIfIsRoot() ?: false
|
return pwGroupV3?.allowAddEntryIfIsRoot() ?: pwGroupV4?.allowAddEntryIfIsRoot() ?: false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,6 +69,11 @@ abstract class PwGroup
|
|||||||
this.childEntries.remove(entry)
|
this.childEntries.remove(entry)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun removeChildren() {
|
||||||
|
this.childGroups.clear()
|
||||||
|
this.childEntries.clear()
|
||||||
|
}
|
||||||
|
|
||||||
override fun toString(): String {
|
override fun toString(): String {
|
||||||
return titleGroup
|
return titleGroup
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ interface PwGroupInterface<Group: PwGroupInterface<Group, Entry>, Entry> : PwNod
|
|||||||
|
|
||||||
fun removeChildEntry(entry: Entry)
|
fun removeChildEntry(entry: Entry)
|
||||||
|
|
||||||
|
fun removeChildren()
|
||||||
|
|
||||||
fun allowAddEntryIfIsRoot(): Boolean
|
fun allowAddEntryIfIsRoot(): Boolean
|
||||||
|
|
||||||
fun doForEachChildAndForIt(entryHandler: NodeHandler<Entry>,
|
fun doForEachChildAndForIt(entryHandler: NodeHandler<Entry>,
|
||||||
|
|||||||
Reference in New Issue
Block a user