Skip to content

Commit d6b1f49

Browse files
author
Patrick Valsecchi
committedMay 1, 2018
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.
1 parent f1aaa14 commit d6b1f49

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed
 

‎src/core/qgscolorschemeregistry.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,15 @@ void QgsColorSchemeRegistry::setRandomStyleColorScheme( QgsColorScheme *scheme )
117117
{
118118
mRandomStyleColors = scheme->fetchColors();
119119

120-
std::random_device rd;
121-
std::mt19937 mt( rd() );
122-
std::uniform_int_distribution<int> colorDist( 0, mRandomStyleColors.count() - 1 );
123-
mNextRandomStyleColorIndex = colorDist( mt );
124-
std::uniform_int_distribution<int> colorDir( 0, 1 );
125-
mNextRandomStyleColorDirection = colorDir( mt ) == 0 ? -1 : 1;
120+
if ( mRandomStyleColors.count() > 0 )
121+
{
122+
std::random_device rd;
123+
std::mt19937 mt( rd() );
124+
std::uniform_int_distribution<int> colorDist( 0, mRandomStyleColors.count() - 1 );
125+
mNextRandomStyleColorIndex = colorDist( mt );
126+
std::uniform_int_distribution<int> colorDir( 0, 1 );
127+
mNextRandomStyleColorDirection = colorDir( mt ) == 0 ? -1 : 1;
128+
}
126129
}
127130
else
128131
{

0 commit comments

Comments
 (0)
Please sign in to comment.