Skip to content

Commit be0e17b

Browse files
committed
Remove old GCPs in georeferencer; clear image on close. Fixes #4310
1 parent d3eae08 commit be0e17b

File tree

3 files changed

+31
-28
lines changed

3 files changed

+31
-28
lines changed

src/plugins/georeferencer/qgsgeorefplugin.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ void QgsGeorefPlugin::initGui()
109109
mQGisIface->addPluginToRasterMenu( tr( "&Georeferencer" ), mActionRunGeoref );
110110
}
111111

112-
// Slot called when the buffer menu item is triggered
113112
void QgsGeorefPlugin::run()
114113
{
115114
if ( !mPluginGui )

src/plugins/georeferencer/qgsgeorefplugingui.cpp

+23-19
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,6 @@ QgsGeorefDockWidget::QgsGeorefDockWidget( const QString & title, QWidget * paren
7070
setObjectName( "GeorefDockWidget" ); // set object name so the position can be saved
7171
}
7272

73-
void QgsGeorefDockWidget::closeEvent( QCloseEvent * ev )
74-
{
75-
if ( widget() && !widget()->close() )
76-
{
77-
ev->ignore();
78-
return;
79-
}
80-
deleteLater();
81-
}
82-
8373
QgsGeorefPluginGui::QgsGeorefPluginGui( QgisInterface* theQgisInterface, QWidget* parent, Qt::WFlags fl )
8474
: QMainWindow( parent, fl )
8575
, mTransformParam( QgsGeorefTransform::InvalidTransform )
@@ -145,12 +135,7 @@ QgsGeorefPluginGui::~QgsGeorefPluginGui()
145135
{
146136
clearGCPData();
147137

148-
// delete layer (and don't signal it as it's our private layer)
149-
if ( mLayer )
150-
{
151-
QgsMapLayerRegistry::instance()->removeMapLayers(
152-
( QStringList() << mLayer->id() ), false );
153-
}
138+
removeOldLayer();
154139

155140
delete mToolZoomIn;
156141
delete mToolZoomOut;
@@ -173,14 +158,23 @@ void QgsGeorefPluginGui::closeEvent( QCloseEvent *e )
173158
else
174159
saveGCPs();
175160
writeSettings();
161+
clearGCPData();
162+
removeOldLayer();
163+
mRasterFileName = "";
176164
e->accept();
177165
return;
178166
case QgsGeorefPluginGui::GCPSILENTSAVE:
179167
if ( !mGCPpointsFileName.isEmpty() )
180168
saveGCPs();
169+
clearGCPData();
170+
removeOldLayer();
171+
mRasterFileName = "";
181172
return;
182173
case QgsGeorefPluginGui::GCPDISCARD:
183174
writeSettings();
175+
clearGCPData();
176+
removeOldLayer();
177+
mRasterFileName = "";
184178
e->accept();
185179
return;
186180
case QgsGeorefPluginGui::GCPCANCEL:
@@ -253,9 +247,7 @@ void QgsGeorefPluginGui::openRaster()
253247
clearGCPData();
254248

255249
//delete any old rasterlayers
256-
if ( mLayer )
257-
QgsMapLayerRegistry::instance()->removeMapLayers(
258-
QStringList() << mLayer->id(), false );
250+
removeOldLayer();
259251

260252
// Add raster
261253
addRaster( mRasterFileName );
@@ -1036,6 +1028,18 @@ void QgsGeorefPluginGui::setupConnections()
10361028
connect( mCanvas, SIGNAL( extentsChanged() ), this, SLOT( extentsChanged() ) );
10371029
}
10381030

1031+
void QgsGeorefPluginGui::removeOldLayer()
1032+
{
1033+
// delete layer (and don't signal it as it's our private layer)
1034+
if ( mLayer )
1035+
{
1036+
QgsMapLayerRegistry::instance()->removeMapLayers(
1037+
( QStringList() << mLayer->id() ), false );
1038+
mLayer = NULL;
1039+
}
1040+
mCanvas->refresh();
1041+
}
1042+
10391043
void QgsGeorefPluginGui::updateIconTheme( QString theme )
10401044
{
10411045
// File actions

src/plugins/georeferencer/qgsgeorefplugingui.h

+8-8
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ class QgsPoint;
3838
class QgsRasterLayer;
3939
class QgsRectangle;
4040

41+
class QgsGeorefDockWidget : public QDockWidget
42+
{
43+
Q_OBJECT
44+
public:
45+
QgsGeorefDockWidget( const QString & title, QWidget * parent = 0, Qt::WindowFlags flags = 0 );
46+
};
47+
4148
class QgsGeorefPluginGui : public QMainWindow, private Ui::QgsGeorefPluginGuiBase
4249
{
4350
Q_OBJECT
@@ -126,6 +133,7 @@ class QgsGeorefPluginGui : public QMainWindow, private Ui::QgsGeorefPluginGuiBas
126133
void createDockWidgets();
127134
void createStatusBar();
128135
void setupConnections();
136+
void removeOldLayer();
129137

130138
// Mapcanvas Plugin
131139
void addRaster( QString file );
@@ -239,12 +247,4 @@ class QgsGeorefPluginGui : public QMainWindow, private Ui::QgsGeorefPluginGuiBas
239247
QDockWidget* mDock;
240248
};
241249

242-
class QgsGeorefDockWidget : public QDockWidget
243-
{
244-
Q_OBJECT
245-
public:
246-
QgsGeorefDockWidget( const QString & title, QWidget * parent = 0, Qt::WindowFlags flags = 0 );
247-
virtual void closeEvent( QCloseEvent * ev );
248-
};
249-
250250
#endif

0 commit comments

Comments
 (0)