Skip to content
Permalink
Browse files

Fix some memory management issues

aka reduce noise in valgrind memory analyzer
  • Loading branch information
m-kuhn committed Jun 15, 2013
1 parent d256fd8 commit 1aa8a17f98dfce5f27488731fb80b18acc77bdaa
@@ -149,13 +149,14 @@ public:
void extend( const QgsFields& other );


QgsField& operator[](int i);
QgsField& operator[](int i) /Factory/;
%MethodCode
int idx = (int)sipConvertFromSequenceIndex(a0, sipCpp->count());
int idx = sipConvertFromSequenceIndex(a0, sipCpp->count());
if (idx < 0)
sipIsErr = 1;
else
sipRes = new QgsField(sipCpp->operator[](idx));

%End

/* SIP_PYOBJECT __getitem__(int key);
@@ -745,44 +745,46 @@ QgisApp::~QgisApp()
#ifdef HAVE_TOUCH
delete mMapTools.mTouch;
#endif
delete mMapTools.mIdentify;
delete mMapTools.mAddFeature;
delete mMapTools.mAddPart;
delete mMapTools.mAddRing;
delete mMapTools.mAnnotation;
delete mMapTools.mChangeLabelProperties;
delete mMapTools.mDeletePart;
delete mMapTools.mDeleteRing;
delete mMapTools.mFeatureAction;
delete mMapTools.mMeasureDist;
delete mMapTools.mMeasureArea;
delete mMapTools.mMeasureAngle;
delete mMapTools.mTextAnnotation;
delete mMapTools.mFormAnnotation;
delete mMapTools.mHtmlAnnotation;
delete mMapTools.mSvgAnnotation;
delete mMapTools.mAnnotation;
delete mMapTools.mAddFeature;
delete mMapTools.mIdentify;
delete mMapTools.mMeasureAngle;
delete mMapTools.mMeasureArea;
delete mMapTools.mMeasureDist;
delete mMapTools.mMoveFeature;
delete mMapTools.mMoveLabel;
delete mMapTools.mNodeTool;
delete mMapTools.mOffsetCurve;
delete mMapTools.mPinLabels;
delete mMapTools.mReshapeFeatures;
delete mMapTools.mSplitFeatures;
delete mMapTools.mRotateFeature;
delete mMapTools.mRotateLabel;
delete mMapTools.mRotatePointSymbolsTool;
delete mMapTools.mSelect;
delete mMapTools.mSelectRectangle;
delete mMapTools.mSelectPolygon;
delete mMapTools.mSelectFreehand;
delete mMapTools.mSelectPolygon;
delete mMapTools.mSelectRadius;
delete mMapTools.mAddRing;
delete mMapTools.mSimplifyFeature;
delete mMapTools.mDeleteRing;
delete mMapTools.mDeletePart;
delete mMapTools.mAddPart;
delete mMapTools.mNodeTool;
delete mMapTools.mRotatePointSymbolsTool;
delete mMapTools.mPinLabels;
delete mMapTools.mSelectRectangle;
delete mMapTools.mShowHideLabels;
delete mMapTools.mMoveLabel;
delete mMapTools.mRotateFeature;
delete mMapTools.mRotateLabel;
delete mMapTools.mChangeLabelProperties;
delete mMapTools.mOffsetCurve;
delete mMapTools.mSimplifyFeature;
delete mMapTools.mSplitFeatures;
delete mMapTools.mSvgAnnotation;
delete mMapTools.mTextAnnotation;

delete mPythonUtils;
delete mpMaptip;

delete mpGpsWidget;

delete mOverviewMapCursor;

deletePrintComposers();
removeAnnotationItems();

@@ -791,6 +793,11 @@ QgisApp::~QgisApp()

// delete map layer registry and provider registry
QgsApplication::exitQgis();

delete QgsProject::instance();

mPythonUtils->exitPython();
delete mPythonUtils;
}

void QgisApp::dragEnterEvent( QDragEnterEvent *event )
@@ -1330,7 +1337,7 @@ void QgisApp::createMenus()
// Help menu
// add What's this button to it
QAction* before = mActionHelpAPI;
mHelpMenu->insertAction( before, QWhatsThis::createAction() );
mHelpMenu->insertAction( before, QWhatsThis::createAction( this ) );
}

void QgisApp::createToolBars()
@@ -1457,7 +1464,7 @@ void QgisApp::createToolBars()

// Help Toolbar

mHelpToolBar->addAction( QWhatsThis::createAction() );
mHelpToolBar->addAction( QWhatsThis::createAction( this ) );

}

@@ -2173,6 +2180,10 @@ bool QgisApp::createDB()
return false;
}
}
else
{
sqlite3_free( errmsg );
}

if ( sqlite3_exec( db, "DROP VIEW vw_srs", 0, 0, &errmsg ) != SQLITE_OK )
{
@@ -155,7 +155,9 @@ void QgsCoordinateTransform::initialise()
}

// init the projections (destination and source)
pj_free( mDestinationProjection );
mDestinationProjection = pj_init_plus( mDestCRS.toProj4().toUtf8() );
pj_free( mSourceProjection );
mSourceProjection = pj_init_plus( mSourceCRS.toProj4().toUtf8() );

#ifdef COORDINATE_TRANSFORM_VERBOSE
@@ -378,8 +378,10 @@ QgsVectorFileWriter::QgsVectorFileWriter(
.arg( attrField.name() )
.arg( QString::fromUtf8( CPLGetLastErrorMsg() ) );
mError = ErrAttributeCreationFailed;
OGR_Fld_Destroy( fld );
return;
}
OGR_Fld_Destroy( fld );

int ogrIdx = OGR_FD_GetFieldIndex( defn, mCodec->fromUnicode( attrField.name() ) );
if ( ogrIdx < 0 )
@@ -201,6 +201,8 @@ QgsVectorLayer::~QgsVectorLayer()

delete mActions;

delete mRendererV2;

//delete remaining overlays

QList<QgsVectorOverlay*>::iterator overlayIt = mOverlays.begin();

0 comments on commit 1aa8a17

Please sign in to comment.
You can’t perform that action at this time.