Skip to content

Commit

Permalink
Remove old GCPs in georeferencer; clear image on close. Fixes #4310
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanW2 authored and jef-n committed May 8, 2012
1 parent 169e412 commit d11603e
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 28 deletions.
1 change: 0 additions & 1 deletion src/plugins/georeferencer/qgsgeorefplugin.cpp
Expand Up @@ -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 )
Expand Down
42 changes: 23 additions & 19 deletions src/plugins/georeferencer/qgsgeorefplugingui.cpp
Expand Up @@ -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 )
Expand Down Expand Up @@ -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;
Expand All @@ -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:
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions src/plugins/georeferencer/qgsgeorefplugingui.h
Expand Up @@ -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
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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

0 comments on commit d11603e

Please sign in to comment.