Skip to content
Permalink
Browse files

Fix some memory leaks

  • Loading branch information
nyalldawson committed Apr 4, 2019
1 parent 3c4b2a7 commit d4420c561df769654fc9e9441949db09fc0198d0
Showing with 5 additions and 5 deletions.
  1. +1 −1 src/app/qgsvectorlayerlegendwidget.cpp
  2. +3 −3 src/core/qgsziputils.cpp
  3. +1 −1 src/gui/qgsmetadatawidget.cpp
@@ -86,7 +86,7 @@ void QgsVectorLayerLegendWidget::setLayer( QgsVectorLayer *layer )

void QgsVectorLayerLegendWidget::populateLegendTreeView( const QHash<QString, QString> &content )
{
QStandardItemModel *model = new QStandardItemModel;
QStandardItemModel *model = new QStandardItemModel( this );
model->setColumnCount( 2 );
model->setHorizontalHeaderLabels( QStringList() << tr( "Symbol" ) << tr( "Text" ) );

@@ -78,8 +78,8 @@ bool QgsZipUtils::unzip( const QString &zipFilename, const QString &dir, QString
size_t len = stat.size;

struct zip_file *file = zip_fopen_index( z, i, 0 );
char *buf = new char[len];
if ( zip_fread( file, buf, len ) != -1 )
std::unique_ptr< char[] > buf( new char[len] );
if ( zip_fread( file, buf.get(), len ) != -1 )
{
QString fileName( stat.name );
QFileInfo newFile( QDir( dir ), fileName );
@@ -98,7 +98,7 @@ bool QgsZipUtils::unzip( const QString &zipFilename, const QString &dir, QString
}
else
{
outFile.write( buf, len );
outFile.write( buf.get(), len );
}
zip_fclose( file );
files.append( newFile.absoluteFilePath() );
@@ -46,7 +46,7 @@ QgsMetadataWidget::QgsMetadataWidget( QWidget *parent, QgsMapLayer *layer )
mDefaultCategories << tr( "Farming" ) << tr( "Climatology Meteorology Atmosphere" ) << tr( "Location" ) << tr( "Intelligence Military" ) << tr( "Transportation" ) << tr( "Structure" ) << tr( "Boundaries" );
mDefaultCategories << tr( "Inland Waters" ) << tr( "Planning Cadastre" ) << tr( "Geoscientific Information" ) << tr( "Elevation" ) << tr( "Health" ) << tr( "Biota" ) << tr( "Oceans" ) << tr( "Environment" );
mDefaultCategories << tr( "Utilities Communication" ) << tr( "Economy" ) << tr( "Society" ) << tr( "Imagery Base Maps Earth Cover" );
mDefaultCategoriesModel = new QStringListModel( mDefaultCategories );
mDefaultCategoriesModel = new QStringListModel( mDefaultCategories, this );
mDefaultCategoriesModel->sort( 0 ); // Sorting using translations
listDefaultCategories->setModel( mDefaultCategoriesModel );

0 comments on commit d4420c5

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