Skip to content

Commit

Permalink
Prevent memory leaks
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Nov 15, 2017
1 parent 447cd18 commit 716ed6b
Showing 1 changed file with 0 additions and 28 deletions.
28 changes: 0 additions & 28 deletions src/core/symbology/qgsstyle.cpp
Expand Up @@ -281,7 +281,6 @@ bool QgsStyle::openDatabase( const QString &filename )
if ( rc )
{
mErrorString = QStringLiteral( "Couldn't open the style database: %1" ).arg( mCurrentDB.errorMessage() );
mCurrentDB.release();
return false;
}

Expand Down Expand Up @@ -614,7 +613,6 @@ int QgsStyle::addTag( const QString &tagname )
statement = mCurrentDB.prepare( query, nErr );
if ( nErr == SQLITE_OK )
( void )sqlite3_step( statement.get() );
statement.release();

QgsSettings settings;
settings.setValue( QStringLiteral( "qgis/symbolsListGroupsIndex" ), 0 );
Expand All @@ -641,8 +639,6 @@ QStringList QgsStyle::tags() const
tagList << QString::fromUtf8( reinterpret_cast< const char * >( sqlite3_column_text( statement.get(), 0 ) ) );
}

statement.release();

return tagList;
}

Expand Down Expand Up @@ -820,9 +816,6 @@ QStringList QgsStyle::findSymbols( StyleEntity type, const QString &qword )
tagids << QString::fromUtf8( ( const char * ) sqlite3_column_text( statement.get(), 0 ) );
}

statement.release();


QString dummy = tagids.join( QStringLiteral( ", " ) );

if ( type == SymbolEntity )
Expand Down Expand Up @@ -892,8 +885,6 @@ bool QgsStyle::tagSymbol( StyleEntity type, const QString &symbol, const QString
tagid = addTag( tag );
}

statement.release();

// Now map the tag to the symbol if it's not already tagged
if ( !symbolHasTag( type, symbol, tag ) )
{
Expand Down Expand Up @@ -938,8 +929,6 @@ bool QgsStyle::detagSymbol( StyleEntity type, const QString &symbol, const QStri
return false;
}

statement.release();

Q_FOREACH ( const QString &tag, tags )
{
query = sqlite3_mprintf( "SELECT id FROM tag WHERE name='%q'", tag.toUtf8().constData() );
Expand Down Expand Up @@ -1040,8 +1029,6 @@ QStringList QgsStyle::tagsOfSymbol( StyleEntity type, const QString &symbol )
}
}

statement.release();

return tagList;
}

Expand Down Expand Up @@ -1092,8 +1079,6 @@ QString QgsStyle::tag( int id ) const
tag = QString::fromUtf8( reinterpret_cast< const char * >( sqlite3_column_text( statement.get(), 0 ) ) );
}

statement.release();

return tag;
}

Expand All @@ -1110,8 +1095,6 @@ int QgsStyle::getId( const QString &table, const QString &name )
id = sqlite3_column_int( statement.get(), 0 );
}

statement.release();

return id;
}

Expand All @@ -1128,8 +1111,6 @@ QString QgsStyle::getName( const QString &table, int id ) const
name = QString::fromUtf8( reinterpret_cast< const char * >( sqlite3_column_text( statement.get(), 0 ) ) );
}

statement.release();

return name;
}

Expand Down Expand Up @@ -1219,8 +1200,6 @@ QgsSymbolGroupMap QgsStyle::smartgroupsListMap()
groupNames.insert( sqlite3_column_int( statement.get(), SmartgroupId ), group );
}

statement.release();

return groupNames;
}

Expand All @@ -1245,8 +1224,6 @@ QStringList QgsStyle::smartgroupNames()
groups << QString::fromUtf8( reinterpret_cast< const char * >( sqlite3_column_text( statement.get(), 0 ) ) );
}

statement.release();

return groups;
}

Expand All @@ -1260,7 +1237,6 @@ QStringList QgsStyle::symbolsOfSmartgroup( StyleEntity type, int id )
int nErr; statement = mCurrentDB.prepare( query, nErr );
if ( !( nErr == SQLITE_OK && sqlite3_step( statement.get() ) == SQLITE_ROW ) )
{
statement.release();
return QStringList();
}
else
Expand Down Expand Up @@ -1384,8 +1360,6 @@ QgsSmartConditionMap QgsStyle::smartgroup( int id )
}
}

statement.release();

return condition;
}

Expand Down Expand Up @@ -1416,8 +1390,6 @@ QString QgsStyle::smartgroupOperator( int id )
op = smartEl.attribute( QStringLiteral( "operator" ) );
}

statement.release();

return op;
}

Expand Down

0 comments on commit 716ed6b

Please sign in to comment.