Skip to content
Permalink
Browse files

Fix clearing groups

  • Loading branch information
nyalldawson committed Jun 28, 2020
1 parent 5c842a6 commit 42a1ed1ce09d96de3a8897861d4f6b42a75d5910
@@ -151,7 +151,7 @@ Python scripts should not use QgsScopedRuntimeProfile directly. Instead, use :py
%End
public:

QgsScopedRuntimeProfile( const QString &name );
QgsScopedRuntimeProfile( const QString &name, const QString &group = "startup" );
%Docstring
Constructor for QgsScopedRuntimeProfile.

@@ -113,6 +113,12 @@ void QgsRuntimeProfilerNode::clear()
mChildren.clear();
}

void QgsRuntimeProfilerNode::removeChildAt( int index )
{
Q_ASSERT( static_cast< std::size_t >( index ) < mChildren.size() );
mChildren.erase( mChildren.begin() + index );
}

void QgsRuntimeProfilerNode::start()
{
mProfileTime.restart();
@@ -263,13 +269,14 @@ double QgsRuntimeProfiler::profileTime( const QString &name, const QString &grou

void QgsRuntimeProfiler::clear( const QString &group )
{
if ( QgsRuntimeProfilerNode *node = pathToNode( group, QString() ) )
for ( int row = mRootNode->childCount() - 1; row >= 0; row-- )
{
// FIX!!!
const QModelIndex index = node2index( node );
beginRemoveRows( index, 0, node->childCount() - 1 );
node->clear();
endRemoveRows();
if ( mRootNode->childAt( row )->data( QgsRuntimeProfilerNode::Group ).toString() == group )
{
beginRemoveRows( QModelIndex(), row, row );
mRootNode->removeChildAt( row );
endRemoveRows();
}
}
}

@@ -562,9 +569,9 @@ QgsRuntimeProfilerNode *QgsRuntimeProfiler::index2node( const QModelIndex &index
// QgsScopedRuntimeProfile
//

QgsScopedRuntimeProfile::QgsScopedRuntimeProfile( const QString &name )
QgsScopedRuntimeProfile::QgsScopedRuntimeProfile( const QString &name, const QString &group )
{
QgsApplication::profiler()->start( name );
QgsApplication::profiler()->start( name, group );
}

QgsScopedRuntimeProfile::~QgsScopedRuntimeProfile()
@@ -102,6 +102,11 @@ class CORE_EXPORT QgsRuntimeProfilerNode
*/
void clear();

/**
* Removes and deletes the child at the specified \a index.
*/
void removeChildAt( int index );

/**
* Starts the node timer.
* \see stop()
@@ -311,7 +316,7 @@ class CORE_EXPORT QgsScopedRuntimeProfile
* Automatically registers the operation in the QgsApplication::profiler() instance
* and starts recording the run time of the operation.
*/
QgsScopedRuntimeProfile( const QString &name );
QgsScopedRuntimeProfile( const QString &name, const QString &group = "startup" );

/**
* Records the final runtime of the operation in the profiler instance.

0 comments on commit 42a1ed1

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