Skip to content

Commit

Permalink
Merge pull request #150 from pontem-network/cleanups
Browse files Browse the repository at this point in the history
fix memory leaks
  • Loading branch information
mkurnikov authored Jun 1, 2024
2 parents f6970a2 + d96e0ac commit 0d95b49
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 28 deletions.
8 changes: 6 additions & 2 deletions src/main/kotlin/org/move/cli/MoveProjectsService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,13 @@ class MoveProjectsService(val project: Project): Disposable {
): CompletableFuture<List<MoveProject>> {
val refreshStatusPublisher =
project.messageBus.syncPublisher(MOVE_PROJECTS_REFRESH_TOPIC)
val syncOnRefreshTopic = {
project.messageBus.takeIf { !it.isDisposed }
?.syncPublisher(MOVE_PROJECTS_REFRESH_TOPIC)
}

val wrappedModifyProjects = { projects: List<MoveProject> ->
refreshStatusPublisher.onRefreshStarted()
syncOnRefreshTopic()?.onRefreshStarted()
modifyProjects(projects)
}
return projects.updateAsync(wrappedModifyProjects)
Expand Down Expand Up @@ -247,7 +251,7 @@ class MoveProjectsService(val project: Project): Disposable {
}
.handle { projects, err ->
val status = err?.toRefreshStatus() ?: MoveRefreshStatus.SUCCESS
refreshStatusPublisher.onRefreshFinished(status)
syncOnRefreshTopic()?.onRefreshFinished(status)
projects
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/kotlin/org/move/cli/MoveProjectsSyncTask.kt
Original file line number Diff line number Diff line change
Expand Up @@ -323,11 +323,11 @@ private class SyncProcessAdapter(
override fun onTextAvailable(event: ProcessEvent, outputType: Key<Any>) {
val text = event.text.trim { it <= ' ' }
if (text.startsWith("FETCHING GIT DEPENDENCY")) {
val git = text.substring("FETCHING GIT DEPENDENCY ".length)
context.withProgressText("Fetching $git")
val gitRepo = text.substring("FETCHING GIT DEPENDENCY".length)
context.withProgressText("Fetching $gitRepo")
}
if (text.startsWith("UPDATING GIT DEPENDENCY")) {
val gitRepo = text.substring("UPDATING GIT DEPENDENCY ".length)
val gitRepo = text.substring("UPDATING GIT DEPENDENCY".length)
context.withProgressText("Updating $gitRepo")
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/main/kotlin/org/move/cli/PluginProjectDisposable.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ import com.intellij.openapi.components.Service
class PluginProjectDisposable : Disposable {
override fun dispose() {
}

override fun toString(): String = "APTOS_PROJECT_DISPOSABLE"
}

@Service(Service.Level.APP)
class PluginApplicationDisposable : Disposable {
override fun dispose() {
}

override fun toString(): String = "APTOS_PLUGIN_DISPOSABLE"
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,6 @@ class MvExternalLinterConfigurable(val project: Project): BoundConfigurable("Ext
RsCommandLineEditor(project, RsCommandLineEditor.EmptyTextFieldCompletionProvider())
// RsCommandLineEditor(project, CargoCommandCompletionProvider(project.cargoProjects, "check ") { null })

// private val channelLabel: JLabel = Label(RsBundle.message("settings.rust.external.linters.channel.label"))
// private val channel: ComboBox<RustChannel> = ComboBox<RustChannel>().apply {
// RustChannel.values()
// .sortedBy { it.index }
// .forEach { addItem(it) }
// }

private val environmentVariables: EnvironmentVariablesComponent = EnvironmentVariablesComponent()

override fun createPanel(): DialogPanel = panel {
Expand All @@ -47,15 +40,6 @@ class MvExternalLinterConfigurable(val project: Project): BoundConfigurable("Ext
componentSet = { component, value -> component.text = value },
prop = state::additionalArguments.toMutableProperty()
)

// channelLabel.labelFor = channel
// cell(channelLabel)
// cell(channel)
// .bind(
// componentGet = { it.item },
// componentSet = { component, value -> component.item = value },
// prop = state::channel.toMutableProperty()
// )
}

row(environmentVariables.label) {
Expand All @@ -75,7 +59,7 @@ class MvExternalLinterConfigurable(val project: Project): BoundConfigurable("Ext
separator()
row {
checkBox("Prevent duplicate errors")
.comment("Skips errors which are implemented by the IDE own analysis engine")
.comment("Skips errors which are implemented by the IDE's own analysis engine")
.bindSelected(state::skipErrorsKnownToIde)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ import com.intellij.openapi.ui.DialogPanel
import com.intellij.openapi.util.Disposer
import com.intellij.ui.components.JBRadioButton
import com.intellij.ui.dsl.builder.*
import com.intellij.ui.layout.ComponentPredicate
import org.move.cli.settings.aptos.ChooseAptosCliPanel
import org.move.cli.settings.sui.ChooseSuiCliPanel
import org.move.openapiext.showSettingsDialog

// panels needs not to be bound to the Configurable itself, as it's sometimes created without calling the `createPanel()`
class PerProjectMoveConfigurable(val project: Project): BoundConfigurable("Move Language") {

private val chooseAptosCliPanel = ChooseAptosCliPanel(versionUpdateListener = null)
private val chooseSuiCliPanel = ChooseSuiCliPanel()

override fun createPanel(): DialogPanel {
val chooseAptosCliPanel = ChooseAptosCliPanel(versionUpdateListener = null)
val chooseSuiCliPanel = ChooseSuiCliPanel()

val configurablePanel =
panel {
val settings = project.moveSettings
Expand Down Expand Up @@ -136,8 +136,10 @@ class PerProjectMoveConfigurable(val project: Project): BoundConfigurable("Move
|| suiPanelData.localSuiPath != settings.localSuiPath
}
}
Disposer.register(this.disposable!!, chooseAptosCliPanel)
Disposer.register(this.disposable!!, chooseSuiCliPanel)
this.disposable?.let {
Disposer.register(it, chooseAptosCliPanel)
Disposer.register(it, chooseSuiCliPanel)
}
return configurablePanel
}

Expand Down

0 comments on commit 0d95b49

Please sign in to comment.