Skip to content

Commit

Permalink
Fix crssync crash during build
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Patrick Valsecchi committed May 1, 2018
1 parent f1aaa14 commit d6b1f49
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/core/qgscolorschemeregistry.cpp
Expand Up @@ -117,12 +117,15 @@ void QgsColorSchemeRegistry::setRandomStyleColorScheme( QgsColorScheme *scheme )
{
mRandomStyleColors = scheme->fetchColors();

std::random_device rd;
std::mt19937 mt( rd() );
std::uniform_int_distribution<int> colorDist( 0, mRandomStyleColors.count() - 1 );
mNextRandomStyleColorIndex = colorDist( mt );
std::uniform_int_distribution<int> colorDir( 0, 1 );
mNextRandomStyleColorDirection = colorDir( mt ) == 0 ? -1 : 1;
if ( mRandomStyleColors.count() > 0 )
{
std::random_device rd;
std::mt19937 mt( rd() );
std::uniform_int_distribution<int> colorDist( 0, mRandomStyleColors.count() - 1 );
mNextRandomStyleColorIndex = colorDist( mt );
std::uniform_int_distribution<int> colorDir( 0, 1 );
mNextRandomStyleColorDirection = colorDir( mt ) == 0 ? -1 : 1;
}
}
else
{
Expand Down

0 comments on commit d6b1f49

Please sign in to comment.