Skip to content
Permalink
Browse files
Fix for crash - ticket #756
git-svn-id: http://svn.osgeo.org/qgis/trunk@8057 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder committed Jan 27, 2008
1 parent 61fd895 commit 4e0c7fee593e7a5f0f0d77dda0b417e41ae2f131
Showing with 10 additions and 46 deletions.
  1. +2 −34 src/plugins/grass/qgsgrassedit.cpp
  2. +1 −4 src/plugins/grass/qgsgrassedit.h
  3. +7 −8 src/plugins/grass/qgsgrassplugin.cpp
@@ -112,7 +112,7 @@ class QgsGrassEditLayer : public QgsMapCanvasItem

bool QgsGrassEdit::mRunning = false;

QgsGrassEdit::QgsGrassEdit ( QgisInterface *iface,
QgsGrassEdit::QgsGrassEdit ( QgisInterface *iface, QgsMapLayer* layer, bool newMap,
QWidget * parent, Qt::WFlags f )
:QMainWindow(parent,f), QgsGrassEditBase (), mInited(false),
mMapTool(0), mCanvasEdit(0), mRubberBandLine(0), mRubberBandIcon(0)
@@ -128,17 +128,12 @@ QgsGrassEdit::QgsGrassEdit ( QgisInterface *iface,
mTool = QgsGrassEdit::NONE;
mSuspend = false;
mIface = iface;
mNewMap = false;
mNewMap = newMap;

mProjectionEnabled = (QgsProject::instance()->readNumEntry("SpatialRefSys","/ProjectionsEnabled",0)!=0);

mCanvas = mIface->getMapCanvas();

// TODO QGIS: crash if canvas is empty

// At moment QgisIface::activeLayer() does not work
QgsMapLayer *layer = (QgsMapLayer *) mIface->activeLayer();

if ( !isEditable(layer) ) return;

//TODO dynamic_cast ?
@@ -198,33 +193,6 @@ void QgsGrassEdit::keyPress(QKeyEvent *e)
}
}

QgsGrassEdit::QgsGrassEdit ( QgisInterface *iface,
QgsGrassProvider *provider,
QWidget * parent, Qt::WFlags f )
:QMainWindow(parent, 0, f), QgsGrassEditBase (), mInited(false),
mMapTool(0), mCanvasEdit(0), mRubberBandLine(0), mRubberBandIcon(0)
{
#ifdef QGISDEBUG
std::cerr << "QgsGrassEdit()" << std::endl;
#endif

setupUi(this);

mRunning = true;
mValid = false;
mTool = QgsGrassEdit::NONE;
mSuspend = false;
mIface = iface;
mNewMap = true;

mProjectionEnabled = (QgsProject::instance()->readNumEntry("SpatialRefSys","/ProjectionsEnabled",0)!=0);

mCanvas = mIface->getMapCanvas();

mProvider = provider;

init();
}

void QgsGrassEdit::init()
{
@@ -116,10 +116,7 @@ class QgsGrassEdit: public QMainWindow, private Ui::QgsGrassEditBase

//! Constructor
QgsGrassEdit ( QgisInterface *iface,
QWidget * parent = 0, Qt::WFlags f = 0 );

QgsGrassEdit ( QgisInterface *iface,
QgsGrassProvider *provider,
QgsMapLayer *layer, bool newMap,
QWidget * parent = 0, Qt::WFlags f = 0 );

// Shared by constructors
@@ -440,7 +440,8 @@ void QgsGrassPlugin::edit()
}

mEditAction->setEnabled(false);
QgsGrassEdit *ed = new QgsGrassEdit( qGisInterface, qGisInterface->getMainWindow(), Qt::WType_Dialog );
QgsGrassEdit *ed = new QgsGrassEdit( qGisInterface, qGisInterface->activeLayer(), false,
qGisInterface->getMainWindow(), Qt::WType_Dialog );

if ( ed->isValid() ) {
ed->show();
@@ -511,24 +512,22 @@ void QgsGrassPlugin::newVector()
Vect_close ( &Map );

// Open in GRASS vector provider
QgsProviderRegistry *pr = QgsProviderRegistry::instance();

QString uri = QgsGrass::getDefaultGisdbase() + "/"
+ QgsGrass::getDefaultLocation() + "/"
+ QgsGrass::getDefaultMapset() + "/"
+ name + "/0_point";

QgsGrassProvider *provider = (QgsGrassProvider *)
pr->getProvider ( "grass", uri );

if ( !provider )

QgsVectorLayer* layer = new QgsVectorLayer(uri, name, "grass");

if ( !layer )
{
QMessageBox::warning( 0, tr("Warning"), tr("New vector created "
"but cannot be opened by data provider.") );
return;
}

QgsGrassEdit *ed = new QgsGrassEdit(qGisInterface, provider,
QgsGrassEdit *ed = new QgsGrassEdit(qGisInterface, layer, true,
qGisInterface->getMainWindow(), Qt::WType_Dialog );

if ( ed->isValid() ) {

0 comments on commit 4e0c7fe

Please sign in to comment.