Skip to content
Browse files
Merge pull request #7152 from rouault/fix_memleaks_qgsstyle
Fix various memleaks in QgsStyle
  • Loading branch information
rouault committed Jun 5, 2018
2 parents 88a49e7 + 0304ec4 commit 370bac99359ac2f6f9a41424c41356d6c6cf3161
@@ -134,6 +134,7 @@ returns 0 if not found
Returns default application-wide style

bool tagSymbol( StyleEntity type, const QString &symbol, const QStringList &tags );
Tags the symbol with the tags in the list
@@ -453,56 +454,10 @@ Is emitted every time a new symbol has been added to the database
void groupsModified();
Is emitted every time a tag or smartgroup has been added, removed, or renamed


bool openDatabase( const QString &filename );
Convenience function to open the DB and return a sqlite3 object

bool runEmptyQuery( char *query, bool freeQuery = true );
Convenience function that would run queries which don't generate return values

:param query: query to run
:param freeQuery: release query memory

:return: success true on success

int getId( const QString &table, const QString &name );
Gets the id from the table for the given name from the database, 0 if not found

QString getName( const QString &table, int id ) const;
Gets the name from the table for the given id from the database, empty if not found

bool updateSymbol( StyleEntity type, const QString &name );
Updates the properties of an existing symbol/colorramp

.. note::

This should not be called separately, only called through addSymbol or addColorRamp

:param type: is either SymbolEntity or ColorrampEntity
:param name: is the name of an existing symbol or a color ramp

:return: Success state of the update operation


* This file has been generated automatically from *
* *
@@ -47,6 +47,7 @@
#include "qgs3drendererregistry.h"
#include "qgslayoutrendercontext.h"
#include "qgssqliteutils.h"
#include "qgsstyle.h"

#include "gps/qgsgpsconnectionregistry.h"
#include "processing/qgsprocessingregistry.h"
@@ -1089,6 +1090,8 @@ void QgsApplication::exitQgis()
// is destroyed before the static variables of the cache, we might use freed memory.


// tear-down GDAL/OGR
@@ -18,6 +18,7 @@
#include "qgssqliteutils.h"

#include <sqlite3.h>
#include <stdarg.h>

void QgsSqlite3Closer::operator()( sqlite3 *database )
@@ -89,3 +90,14 @@ sqlite3_statement_unique_ptr sqlite3_database_unique_ptr::prepare( const QString
s.reset( preparedStatement );
return s;

QString QgsSqlite3Mprintf( const char *format, ... )
va_list ap;
va_start( ap, format );
char *c_str = sqlite3_vmprintf( format, ap );
va_end( ap );
QString res( QString::fromUtf8( c_str ) );
sqlite3_free( c_str );
return res;
@@ -135,7 +135,15 @@ class CORE_EXPORT sqlite3_database_unique_ptr : public std::unique_ptr< sqlite3,
* argument will be filled with the sqlite3 result code.
sqlite3_statement_unique_ptr prepare( const QString &sql, int &resultCode ) const;


* Wraps sqlite3_mprintf() by automatically freeing the memory.
* \note not available in Python bindings.
* \since QGIS 3.2
QString CORE_EXPORT QgsSqlite3Mprintf( const char *format, ... );


0 comments on commit 370bac9

Please sign in to comment.