Skip to content

Commit b81c63c

Browse files
committed
globe fix: don't crash on quit
1 parent 13cc17d commit b81c63c

File tree

3 files changed

+31
-30
lines changed

3 files changed

+31
-30
lines changed

src/plugins/globe/globe_plugin.cpp

100644100755
Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -69,24 +69,25 @@ static const QgisPlugin::PLUGINTYPE sPluginType = QgisPlugin::UI;
6969

7070
//constructor
7171
GlobePlugin::GlobePlugin( QgisInterface* theQgisInterface )
72-
: QgisPlugin( sName, sDescription, sPluginVersion, sPluginType ),
73-
mQGisIface( theQgisInterface ),
74-
mQActionPointer( NULL ),
75-
mQActionSettingsPointer( NULL ),
76-
viewer(),
77-
mQDockWidget( tr( "Globe" ) ),
78-
mSettingsDialog( &viewer, theQgisInterface->mainWindow(), QgisGui::ModalDialogFlags ),
79-
mQgisMapLayer( 0 ),
80-
mTileSource( 0 ),
81-
mElevationManager( NULL ),
82-
mObjectPlacer( NULL )
72+
: QgisPlugin( sName, sDescription, sPluginVersion, sPluginType )
73+
, mQGisIface( theQgisInterface )
74+
, mQActionPointer( NULL )
75+
, mQActionSettingsPointer( NULL )
76+
, viewer()
77+
, mQgisMapLayer( 0 )
78+
, mTileSource( 0 )
79+
, mElevationManager( NULL )
80+
, mObjectPlacer( NULL )
8381
{
8482
mIsGlobeRunning = false;
8583
//needed to be "seen" by other plugins by doing
8684
//iface.mainWindow().findChild( QObject, "globePlugin" )
8785
//needed until https://trac.osgeo.org/qgis/changeset/15224
8886
this->setObjectName( "globePlugin" );
8987
this->setParent( theQgisInterface->mainWindow() );
88+
89+
mSettingsDialog = new QgsGlobePluginDialog( &viewer, theQgisInterface->mainWindow(), QgisGui::ModalDialogFlags );
90+
mQDockWidget = new QDockWidgetGlobe( tr( "Globe" ), theQgisInterface->mainWindow() );
9091
}
9192

9293
//destructor
@@ -190,19 +191,19 @@ void GlobePlugin::initGui()
190191
//Add menu
191192
mQGisIface->addPluginToMenu( tr( "&Globe" ), mQActionPointer );
192193
mQGisIface->addPluginToMenu( tr( "&Globe" ), mQActionSettingsPointer );
193-
mQDockWidget.setWidget( &viewer );
194+
mQDockWidget->setWidget( &viewer );
194195

195196
connect( mQGisIface->mapCanvas() , SIGNAL( extentsChanged() ),
196197
this, SLOT( extentsChanged() ) );
197198
connect( mQGisIface->mapCanvas(), SIGNAL( layersChanged() ),
198199
this, SLOT( layersChanged() ) );
199-
connect( &mSettingsDialog, SIGNAL( elevationDatasourcesChanged() ),
200+
connect( mSettingsDialog, SIGNAL( elevationDatasourcesChanged() ),
200201
this, SLOT( layersChanged() ) );
201202
connect( mQGisIface->mainWindow(), SIGNAL( projectRead() ), this,
202203
SLOT( projectReady() ) );
203204
connect( mQGisIface, SIGNAL( newProjectCreated() ), this,
204205
SLOT( blankProjectReady() ) );
205-
connect( &mQDockWidget, SIGNAL( globeClosed() ), this,
206+
connect( mQDockWidget, SIGNAL( globeClosed() ), this,
206207
SLOT( setGlobeNotRunning() ) );
207208
connect( this, SIGNAL( xyCoordinates( const QgsPoint & ) ),
208209
mQGisIface->mapCanvas(), SIGNAL( xyCoordinates( const QgsPoint & ) ) );
@@ -214,7 +215,7 @@ void GlobePlugin::run()
214215
if ( !getenv( "OSGNOTIFYLEVEL" ) ) osgEarth::setNotifyLevel( osg::DEBUG_INFO );
215216
#endif
216217

217-
mQGisIface->addDockWidget( Qt::RightDockWidgetArea, &mQDockWidget );
218+
mQGisIface->addDockWidget( Qt::RightDockWidgetArea, mQDockWidget );
218219

219220
viewer.show();
220221

@@ -266,8 +267,8 @@ void GlobePlugin::run()
266267

267268
void GlobePlugin::settings()
268269
{
269-
mSettingsDialog.updatePointLayers();
270-
if ( mSettingsDialog.exec() )
270+
mSettingsDialog->updatePointLayers();
271+
if ( mSettingsDialog->exec() )
271272
{
272273
//viewer stereo settings set by mSettingsDialog and stored in QSettings
273274
}
@@ -324,12 +325,12 @@ void GlobePlugin::setupMap()
324325
mObjectPlacer = new osgEarth::Util::ObjectPlacer( mMapNode );
325326

326327
// place 3D model on point layer
327-
if ( mSettingsDialog.modelLayer() && !mSettingsDialog.modelPath().isEmpty() )
328+
if ( mSettingsDialog->modelLayer() && !mSettingsDialog->modelPath().isEmpty() )
328329
{
329-
osg::Node* model = osgDB::readNodeFile( mSettingsDialog.modelPath().toStdString() );
330+
osg::Node* model = osgDB::readNodeFile( mSettingsDialog->modelPath().toStdString() );
330331
if ( model )
331332
{
332-
QgsVectorLayer* layer = mSettingsDialog.modelLayer();
333+
QgsVectorLayer* layer = mSettingsDialog->modelLayer();
333334
QgsAttributeList fetchAttributes;
334335
layer->select( fetchAttributes ); //TODO: select only visible features
335336
QgsFeature feature;
@@ -346,13 +347,13 @@ void GlobePlugin::setupMap()
346347
void GlobePlugin::projectReady()
347348
{
348349
blankProjectReady();
349-
mSettingsDialog.readElevationDatasources();
350+
mSettingsDialog->readElevationDatasources();
350351
}
351352

352353
void GlobePlugin::blankProjectReady()
353354
{ //needs at least http://trac.osgeo.org/qgis/changeset/14452
354-
mSettingsDialog.elevationDatasources()->clearContents();
355-
mSettingsDialog.elevationDatasources()->setRowCount( 0 );
355+
mSettingsDialog->elevationDatasources()->clearContents();
356+
mSettingsDialog->elevationDatasources()->setRowCount( 0 );
356357
}
357358

358359
void GlobePlugin::showCurrentCoordinates( double lon, double lat )
@@ -696,7 +697,7 @@ void GlobePlugin::layersChanged()
696697
// Add elevation layers
697698
QSettings settings;
698699
QString cacheDirectory = settings.value( "cache/directory", QgsApplication::qgisSettingsDirPath() + "cache" ).toString();
699-
QTableWidget* table = mSettingsDialog.elevationDatasources();
700+
QTableWidget* table = mSettingsDialog->elevationDatasources();
700701
for ( int i = 0; i < table->rowCount(); ++i )
701702
{
702703
QString type = table->item( i, 0 )->text();

src/plugins/globe/globe_plugin.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ class GlobePlugin : public QObject, public QgisPlugin
110110
//! OSG Viewer
111111
QgsOsgViewer viewer;
112112
//! Dock widget for viewer
113-
QDockWidgetGlobe mQDockWidget;
113+
QDockWidgetGlobe *mQDockWidget;
114114
//! Settings Dialog
115-
QgsGlobePluginDialog mSettingsDialog;
115+
QgsGlobePluginDialog *mSettingsDialog;
116116
//! OSG root node
117117
osg::Group* mRootNode;
118118
//! Map node

src/plugins/globe/globe_plugin_dialog.cpp

100644100755
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ QgsGlobePluginDialog::~QgsGlobePluginDialog()
5858
QString QgsGlobePluginDialog::openRasterFile()
5959
{
6060
//see http://www.gdal.org/formats_list.html
61-
const char* filter = "GDAL files (*.dem *.tif *.tiff *.jpg *.jpeg *.asc) \
62-
;;DEM files (*.dem) \
63-
;;All files (*.*)";
61+
QString filter = tr( "GDAL files" ) + " (*.dem *.tif *.tiff *.jpg *.jpeg *.asc);;"
62+
+ tr( "DEM files" ) + " (*.dem);;"
63+
+ tr( "All files" ) + " (*.*)";
6464
QString path = QFileDialog::getOpenFileName( this,
6565
tr( "Open raster file" ),
6666
QDir::homePath(),
67-
tr( filter ) );
67+
filter );
6868

6969
return path;
7070
}

0 commit comments

Comments
 (0)