Skip to content

Commit

Permalink
Fixed VaultEditorDialog EditorImpl memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
sadv1r authored and sadv1r committed May 13, 2021
1 parent d625311 commit fe84a5c
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class VaultEditorDialog(
) : DialogWrapper(true) {

private lateinit var decryptedDocument: Document
private lateinit var editor: EditorEx

init {
init()
Expand All @@ -34,7 +35,7 @@ class VaultEditorDialog(
decryptedDocumentData.toString(Charsets.UTF_8).trim().replace("\r\n|\r".toRegex(), "\n")
)
decryptedDocument.setReadOnly(false)
val editor: EditorEx = editorFactory.createEditor(decryptedDocument) as EditorEx
editor = editorFactory.createEditor(decryptedDocument) as EditorEx

setHighlighting(editor)
editor.setCaretEnabled(true)
Expand All @@ -53,6 +54,12 @@ class VaultEditorDialog(
}
}

override fun dispose() {
EditorFactory.getInstance().releaseEditor(editor)

super.dispose()
}

private fun setHighlighting(editor: EditorEx) {
val fileType = vault.getFileType()
if (fileType === UnknownFileType.INSTANCE) {
Expand Down

0 comments on commit fe84a5c

Please sign in to comment.