@@ -88,9 +88,11 @@ class EnvironmentsDropdownPanel(
8888 override fun reset () {
8989 rebuildInBackground()
9090 }
91-
91+ private var isDisposed = false ;
9292 override fun dispose () {
93+ if (isDisposed) return ;
9394 messageBusConnection.dispose()
95+ isDisposed = true ;
9496 }
9597
9698 private fun rebuildInBackground () {
@@ -236,8 +238,8 @@ class EnvironmentsDropdownPanel(
236238
237239 comboBox.addActionListener { event ->
238240 val cb = event.source as ComboBox <String >
239- var selectedEnv = cb.selectedItem as String
240- if (selectedEnv == NO_ENVIRONMENTS_MESSAGE ) return @addActionListener
241+ var selectedEnv = cb.selectedItem as String ? // can be null if connection error and all item being removed from list (current logic)
242+ if (selectedEnv == null || selectedEnv == NO_ENVIRONMENTS_MESSAGE ) return @addActionListener
241243 selectedEnv = adjustBackEnvNameIfNeeded(selectedEnv)
242244 val currEnv : String ? = environmentsSupplier.getCurrent()
243245
@@ -259,15 +261,16 @@ class EnvironmentsDropdownPanel(
259261 if (currentEnv != null ) comboBox.selectedItem = buildLinkText(currentEnv)
260262
261263 comboBox.isEditable = false
262-
263- if (comboBox.itemCount == 0 ) {
264- // display default value
265- comboBox.addItem(NO_ENVIRONMENTS_MESSAGE )
266- }
267264 if (backendConnectionMonitor.isConnectionError()) {
268265 comboBox.removeAllItems()
269266 comboBox.addItem(NO_ENVIRONMENTS_MESSAGE )
270267 }
268+ else {
269+ if (comboBox.itemCount == 0 ) {
270+ // display default value
271+ comboBox.addItem(NO_ENVIRONMENTS_MESSAGE )
272+ }
273+ }
271274
272275 this .add(comboBox)
273276
0 commit comments