forked from Lonami/Talaria
Wrap freeDialogs call inside a finally block
For instance, LocalDateTime.parse could fail, and then the dialogs would be leaked.
This commit is contained in:
parent
442b019134
commit
07d0e5e505
|
@ -16,6 +16,7 @@ class NativeDialogRepository : DialogRepository {
|
||||||
val dialogs = mutableListOf<Dialog>()
|
val dialogs = mutableListOf<Dialog>()
|
||||||
|
|
||||||
val dialogPtr = Native.getDialogs()
|
val dialogPtr = Native.getDialogs()
|
||||||
|
try {
|
||||||
val dialogCount = Native.dialogCount(dialogPtr)
|
val dialogCount = Native.dialogCount(dialogPtr)
|
||||||
for (i in 0 until dialogCount) {
|
for (i in 0 until dialogCount) {
|
||||||
dialogs.add(
|
dialogs.add(
|
||||||
|
@ -40,7 +41,9 @@ class NativeDialogRepository : DialogRepository {
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
Native.freeDialogs(dialogPtr)
|
Native.freeDialogs(dialogPtr)
|
||||||
|
}
|
||||||
|
|
||||||
return dialogs
|
return dialogs
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue