mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-05 00:09:32 -04:00
Don't allow users to set maximum thread count for rendering to 1
(This setting can sometimes unwantedly occur when using the same profile across sessions of newer to very old QGIS versions) The option is a misleading, as it's actually setting the global thread limit for the entire QGIS application. If we allow this to be set to a limit of 1 thread, then deadlocks occur from the QImage internals in unpredictable ways.
This commit is contained in:
parent
4dad60215a
commit
06b3678a57
@ -695,7 +695,7 @@ Set maximum concurrent thread count
|
||||
|
||||
.. note::
|
||||
|
||||
must be between 1 and \#cores, -1 means use all available cores
|
||||
must be between 2 and \#cores, -1 means use all available cores
|
||||
|
||||
.. versionadded:: 2.4
|
||||
%End
|
||||
|
@ -32,8 +32,8 @@ QgsRenderingOptionsWidget::QgsRenderingOptionsWidget( QWidget *parent )
|
||||
QgsSettings settings;
|
||||
chkAddedVisibility->setChecked( settings.value( QStringLiteral( "/qgis/new_layers_visible" ), true ).toBool() );
|
||||
|
||||
spinMaxThreads->setRange( 0, QThread::idealThreadCount() );
|
||||
spinMaxThreads->setClearValue( 0, tr( "All Available (%1)" ).arg( QThread::idealThreadCount() ) );
|
||||
spinMaxThreads->setRange( 1, QThread::idealThreadCount() );
|
||||
spinMaxThreads->setClearValue( 1, tr( "All Available (%1)" ).arg( QThread::idealThreadCount() ) );
|
||||
if ( QgsApplication::maxThreads() != -1 )
|
||||
spinMaxThreads->setValue( QgsApplication::maxThreads() );
|
||||
else
|
||||
|
@ -2351,10 +2351,13 @@ void QgsApplication::setMaxThreads( int maxThreads )
|
||||
QgsDebugMsgLevel( QStringLiteral( "maxThreads: %1" ).arg( maxThreads ), 2 );
|
||||
|
||||
// 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;
|
||||
|
||||
// force at least 2 threads -- anything less risks deadlocks within Qt itself (e.g in QImage internal mutexes)
|
||||
if ( maxThreads > 0 && maxThreads < 2 )
|
||||
maxThreads = 2;
|
||||
|
||||
// save value
|
||||
ABISYM( sMaxThreads ) = maxThreads;
|
||||
|
||||
|
@ -670,7 +670,7 @@ class CORE_EXPORT QgsApplication : public QApplication
|
||||
|
||||
/**
|
||||
* Set maximum concurrent thread count
|
||||
* \note must be between 1 and \#cores, -1 means use all available cores
|
||||
* \note must be between 2 and \#cores, -1 means use all available cores
|
||||
* \since QGIS 2.4
|
||||
*/
|
||||
static void setMaxThreads( int maxThreads );
|
||||
|
Loading…
x
Reference in New Issue
Block a user