Skip to content

Commit

Permalink
change qsettings in qgsoptions, not qgsapplication
Browse files Browse the repository at this point in the history
  • Loading branch information
etiennesky committed May 17, 2014
1 parent e879a8b commit a4e974a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
7 changes: 3 additions & 4 deletions src/app/qgsoptions.cpp
Expand Up @@ -1076,10 +1076,9 @@ void QgsOptions::saveOptions()
settings.setValue( "/qgis/enable_anti_aliasing", chkAntiAliasing->isChecked() );
settings.setValue( "/qgis/enable_render_caching", chkUseRenderCaching->isChecked() );
settings.setValue( "/qgis/parallel_rendering", chkParallelRendering->isChecked() );
if ( chkMaxThreads->isChecked() )
QgsApplication::setMaxThreads( spinMaxThreads->value() );
else
QgsApplication::setMaxThreads( -1 );
int maxThreads = chkMaxThreads->isChecked() ? spinMaxThreads->value() : -1;
QgsApplication::setMaxThreads( maxThreads );
settings.setValue( "/qgis/max_threads", maxThreads );

settings.setValue( "/qgis/map_update_interval", spinMapUpdateInterval->value() );
settings.setValue( "/qgis/legendDoubleClickAction", cmbLegendDoubleClickAction->currentIndex() );
Expand Down
13 changes: 6 additions & 7 deletions src/core/qgsapplication.cpp
Expand Up @@ -1023,25 +1023,24 @@ bool QgsApplication::createDB( QString *errorMessage )
return true;
}

void QgsApplication::setMaxThreads( int maxThreads )
{
qDebug("max threads: %d",maxThreads);
void QgsApplication::setMaxThreads( int maxThreads )
{
QgsDebugMsg( QString( "maxThreads: %1" ).arg( maxThreads ) );

// make sure value is between 1 and #cores, if not set to -1 (use #cores)
// 0 could be used to disable any parallel processing
if ( maxThreads < 1 || maxThreads > QThread::idealThreadCount() )
maxThreads = -1;
maxThreads = -1;

// save value
ABISYM( mMaxThreads ) = maxThreads;
QSettings().setValue( "/qgis/max_threads", maxThreads );

// if -1 use #cores
if ( maxThreads == -1 )
maxThreads = QThread::idealThreadCount();
maxThreads = QThread::idealThreadCount();

// set max thread count in QThreadPool
QThreadPool::globalInstance()->setMaxThreadCount( maxThreads );
qDebug( "set QThreadPool max thread count to %d", QThreadPool::globalInstance()->maxThreadCount() );
QgsDebugMsg( QString( "set QThreadPool max thread count to %d" ).arg( QThreadPool::globalInstance()->maxThreadCount() ) );
}

0 comments on commit a4e974a

Please sign in to comment.