diff --git a/src/plugins/georeferencer/qgsgeorefplugin.cpp b/src/plugins/georeferencer/qgsgeorefplugin.cpp index 862a21f13810..ab18ab3c3ee2 100644 --- a/src/plugins/georeferencer/qgsgeorefplugin.cpp +++ b/src/plugins/georeferencer/qgsgeorefplugin.cpp @@ -109,7 +109,6 @@ void QgsGeorefPlugin::initGui() mQGisIface->addPluginToRasterMenu( tr( "&Georeferencer" ), mActionRunGeoref ); } -// Slot called when the buffer menu item is triggered void QgsGeorefPlugin::run() { if ( !mPluginGui ) diff --git a/src/plugins/georeferencer/qgsgeorefplugingui.cpp b/src/plugins/georeferencer/qgsgeorefplugingui.cpp index 86db66b655dc..d961eebbbee2 100644 --- a/src/plugins/georeferencer/qgsgeorefplugingui.cpp +++ b/src/plugins/georeferencer/qgsgeorefplugingui.cpp @@ -70,16 +70,6 @@ QgsGeorefDockWidget::QgsGeorefDockWidget( const QString & title, QWidget * paren setObjectName( "GeorefDockWidget" ); // set object name so the position can be saved } -void QgsGeorefDockWidget::closeEvent( QCloseEvent * ev ) -{ - if ( widget() && !widget()->close() ) - { - ev->ignore(); - return; - } - deleteLater(); -} - QgsGeorefPluginGui::QgsGeorefPluginGui( QgisInterface* theQgisInterface, QWidget* parent, Qt::WFlags fl ) : QMainWindow( parent, fl ) , mTransformParam( QgsGeorefTransform::InvalidTransform ) @@ -145,12 +135,7 @@ QgsGeorefPluginGui::~QgsGeorefPluginGui() { clearGCPData(); - // delete layer (and don't signal it as it's our private layer) - if ( mLayer ) - { - QgsMapLayerRegistry::instance()->removeMapLayers( - ( QStringList() << mLayer->id() ), false ); - } + removeOldLayer(); delete mToolZoomIn; delete mToolZoomOut; @@ -173,14 +158,23 @@ void QgsGeorefPluginGui::closeEvent( QCloseEvent *e ) else saveGCPs(); writeSettings(); + clearGCPData(); + removeOldLayer(); + mRasterFileName = ""; e->accept(); return; case QgsGeorefPluginGui::GCPSILENTSAVE: if ( !mGCPpointsFileName.isEmpty() ) saveGCPs(); + clearGCPData(); + removeOldLayer(); + mRasterFileName = ""; return; case QgsGeorefPluginGui::GCPDISCARD: writeSettings(); + clearGCPData(); + removeOldLayer(); + mRasterFileName = ""; e->accept(); return; case QgsGeorefPluginGui::GCPCANCEL: @@ -253,9 +247,7 @@ void QgsGeorefPluginGui::openRaster() clearGCPData(); //delete any old rasterlayers - if ( mLayer ) - QgsMapLayerRegistry::instance()->removeMapLayers( - QStringList() << mLayer->id(), false ); + removeOldLayer(); // Add raster addRaster( mRasterFileName ); @@ -1036,6 +1028,18 @@ void QgsGeorefPluginGui::setupConnections() connect( mCanvas, SIGNAL( extentsChanged() ), this, SLOT( extentsChanged() ) ); } +void QgsGeorefPluginGui::removeOldLayer() +{ + // delete layer (and don't signal it as it's our private layer) + if ( mLayer ) + { + QgsMapLayerRegistry::instance()->removeMapLayers( + ( QStringList() << mLayer->id() ), false ); + mLayer = NULL; + } + mCanvas->refresh(); +} + void QgsGeorefPluginGui::updateIconTheme( QString theme ) { // File actions diff --git a/src/plugins/georeferencer/qgsgeorefplugingui.h b/src/plugins/georeferencer/qgsgeorefplugingui.h index 12f75e3c6ba5..9705a271d20c 100644 --- a/src/plugins/georeferencer/qgsgeorefplugingui.h +++ b/src/plugins/georeferencer/qgsgeorefplugingui.h @@ -38,6 +38,13 @@ class QgsPoint; class QgsRasterLayer; class QgsRectangle; +class QgsGeorefDockWidget : public QDockWidget +{ + Q_OBJECT + public: + QgsGeorefDockWidget( const QString & title, QWidget * parent = 0, Qt::WindowFlags flags = 0 ); +}; + class QgsGeorefPluginGui : public QMainWindow, private Ui::QgsGeorefPluginGuiBase { Q_OBJECT @@ -126,6 +133,7 @@ class QgsGeorefPluginGui : public QMainWindow, private Ui::QgsGeorefPluginGuiBas void createDockWidgets(); void createStatusBar(); void setupConnections(); + void removeOldLayer(); // Mapcanvas Plugin void addRaster( QString file ); @@ -239,12 +247,4 @@ class QgsGeorefPluginGui : public QMainWindow, private Ui::QgsGeorefPluginGuiBas QDockWidget* mDock; }; -class QgsGeorefDockWidget : public QDockWidget -{ - Q_OBJECT - public: - QgsGeorefDockWidget( const QString & title, QWidget * parent = 0, Qt::WindowFlags flags = 0 ); - virtual void closeEvent( QCloseEvent * ev ); -}; - #endif