Fix crssync crash during build

On my machine, crssync dies with a core dump during the build of QGIS.
Infinite loop because there is no color defined in the scheme it loads.
This commit is contained in:
Patrick Valsecchi 2018-05-01 16:46:31 +02:00
parent f1aaa144ff
commit d6b1f4946f
No known key found for this signature in database
GPG Key ID: 7C661185B42AF223

View File

@ -117,6 +117,8 @@ void QgsColorSchemeRegistry::setRandomStyleColorScheme( QgsColorScheme *scheme )
{
mRandomStyleColors = scheme->fetchColors();
if ( mRandomStyleColors.count() > 0 )
{
std::random_device rd;
std::mt19937 mt( rd() );
std::uniform_int_distribution<int> colorDist( 0, mRandomStyleColors.count() - 1 );
@ -124,6 +126,7 @@ void QgsColorSchemeRegistry::setRandomStyleColorScheme( QgsColorScheme *scheme )
std::uniform_int_distribution<int> colorDir( 0, 1 );
mNextRandomStyleColorDirection = colorDir( mt ) == 0 ? -1 : 1;
}
}
else
{
mRandomStyleColors.clear();