Skip to content
Permalink
Browse files

do not destroy layers created outside the dialog (fix #7903)

  • Loading branch information
brushtyler committed May 27, 2013
1 parent cb1e47b commit 61285a9d96a38c8640357563e2ddd7cd9c808534
Showing with 10 additions and 3 deletions.
  1. +10 −3 python/plugins/db_manager/dlg_import_vector.py
@@ -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

self.populateSchemas()
self.populateTables()
self.populateLayers()
@@ -107,19 +110,21 @@ def populateLayers(self):
self.cboInputLayer.addItem( layer.name(), 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:
self.inLayer.deleteLater()
if self.inLayerMustBeDestroyed:
self.inLayer.deleteLater()
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)
@@ -159,10 +164,12 @@ def updateInputLayer(self):
return False

self.inLayer = layer
self.inLayerMustBeDestroyed = True

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

# update the output table name
self.cboTable.setEditText(self.inLayer.name())

0 comments on commit 61285a9

Please sign in to comment.
You can’t perform that action at this time.