Skip to content


do not destroy layers created outside the dialog (fix #7903)
Browse files Browse the repository at this point in the history
  • Loading branch information
brushtyler committed May 27, 2013
1 parent cb1e47b commit 61285a9
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions python/plugins/db_manager/
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ def __init__(self, inLayer, outDb, outUri, parent=None):

self.mode = self.ASK_FOR_INPUT_MODE if self.inLayer is None else self.HAS_INPUT_MODE

# used to delete the inlayer whether created inside this dialog
self.inLayerMustBeDestroyed = False

Expand Down Expand Up @@ -107,19 +110,21 @@ def populateLayers(self):
self.cboInputLayer.addItem(, index )

def deleteInputLayer(self):
""" destroy the input layer instance, but only if it was
""" unset the input layer, then destroy it but only if it was
created from this dialog """
if self.mode == self.ASK_FOR_INPUT_MODE and self.inLayer:
if self.inLayerMustBeDestroyed:
self.inLayer = None
self.inLayerMustBeDestroyed = False
return True
return False

def chooseInputFile(self):
vectorFormats = qgis.core.QgsProviderRegistry.instance().fileVectorFilters()
# get last used dir and format
settings = QSettings()
lastDir = settings.value("/db_manager/lastUsedDir", "").toString()
lastDir = settings.value("/db_manager/lastUsedDir", "").toString()
lastVectorFormat = settings.value("/UI/lastVectorFileFilter", "").toString()
# ask for a filename
filename = QFileDialog.getOpenFileName(self, "Choose the file to import", lastDir, vectorFormats, lastVectorFormat)
Expand Down Expand Up @@ -159,10 +164,12 @@ def updateInputLayer(self):
return False

self.inLayer = layer
self.inLayerMustBeDestroyed = True

legendIndex = self.cboInputLayer.itemData( index ).toInt()[0]
self.inLayer = iface.legendInterface().layers()[ legendIndex ]
self.inLayerMustBeDestroyed = False

# update the output table name
Expand Down

0 comments on commit 61285a9

Please sign in to comment.