@@ -768,6 +768,13 @@ void QgsPalLayerSettings::readDataDefinedProperty( QgsVectorLayer* layer,
768
768
bufferDraw = true ;
769
769
layer->setCustomProperty ( " labeling/bufferDraw" , true );
770
770
}
771
+
772
+ // fix for scale visibility limits triggered off of just its data defined values in the past (<2.0)
773
+ if ( oldIndx == 16 || oldIndx == 17 ) // old minScale and maxScale enums
774
+ {
775
+ scaleVisibility = true ;
776
+ layer->setCustomProperty ( " labeling/scaleVisibility" , true );
777
+ }
771
778
}
772
779
773
780
// remove old-style field index-based property
@@ -853,7 +860,7 @@ void QgsPalLayerSettings::readFromLayer( QgsVectorLayer* layer )
853
860
// text buffer
854
861
double bufSize = layer->customProperty ( " labeling/bufferSize" , QVariant ( 0.0 ) ).toDouble ();
855
862
856
- // fix for buffer being keyed off of just its size in the past
863
+ // fix for buffer being keyed off of just its size in the past (<2.0)
857
864
QVariant drawBuffer = layer->customProperty ( " labeling/bufferDraw" , QVariant () );
858
865
if ( drawBuffer.isValid () )
859
866
{
@@ -937,9 +944,30 @@ void QgsPalLayerSettings::readFromLayer( QgsVectorLayer* layer )
937
944
priority = layer->customProperty ( " labeling/priority" ).toInt ();
938
945
939
946
// rendering
940
- scaleVisibility = layer->customProperty ( " labeling/scaleVisibility" ).toBool ();
941
- scaleMin = layer->customProperty ( " labeling/scaleMin" , QVariant ( 1 ) ).toInt ();
942
- scaleMax = layer->customProperty ( " labeling/scaleMax" , QVariant ( 10000000 ) ).toInt ();
947
+ int scalemn = layer->customProperty ( " labeling/scaleMin" , QVariant ( 0 ) ).toInt ();
948
+ int scalemx = layer->customProperty ( " labeling/scaleMax" , QVariant ( 0 ) ).toInt ();
949
+
950
+ // fix for scale visibility limits being keyed off of just its values in the past (<2.0)
951
+ QVariant scalevis = layer->customProperty ( " labeling/scaleVisibility" , QVariant () );
952
+ if ( scalevis.isValid () )
953
+ {
954
+ scaleVisibility = scalevis.toBool ();
955
+ scaleMin = scalemn;
956
+ scaleMax = scalemx;
957
+ }
958
+ else if ( scalemn > 0 || scalemx > 0 )
959
+ {
960
+ scaleVisibility = true ;
961
+ scaleMin = scalemn;
962
+ scaleMax = scalemx;
963
+ }
964
+ else
965
+ {
966
+ // keep scaleMin and scaleMax at new 1.0 defaults (1 and 10000000, were 0 and 0)
967
+ scaleVisibility = false ;
968
+ }
969
+
970
+
943
971
fontLimitPixelSize = layer->customProperty ( " labeling/fontLimitPixelSize" , QVariant ( false ) ).toBool ();
944
972
fontMinPixelSize = layer->customProperty ( " labeling/fontMinPixelSize" , QVariant ( 0 ) ).toInt ();
945
973
fontMaxPixelSize = layer->customProperty ( " labeling/fontMaxPixelSize" , QVariant ( 10000 ) ).toInt ();
@@ -1496,7 +1524,14 @@ void QgsPalLayerSettings::registerFeature( QgsVectorLayer* layer, QgsFeature& f
1496
1524
minScale = mins;
1497
1525
}
1498
1526
}
1499
- if ( context.rendererScale () < minScale )
1527
+
1528
+ // scales closer than 1:1
1529
+ if ( minScale < 0 )
1530
+ {
1531
+ minScale = 1 / qAbs ( minScale );
1532
+ }
1533
+
1534
+ if ( minScale != 0 && context.rendererScale () < minScale )
1500
1535
{
1501
1536
return ;
1502
1537
}
@@ -1513,7 +1548,14 @@ void QgsPalLayerSettings::registerFeature( QgsVectorLayer* layer, QgsFeature& f
1513
1548
maxScale = maxs;
1514
1549
}
1515
1550
}
1516
- if ( context.rendererScale () > maxScale )
1551
+
1552
+ // scales closer than 1:1
1553
+ if ( maxScale < 0 )
1554
+ {
1555
+ maxScale = 1 / qAbs ( maxScale );
1556
+ }
1557
+
1558
+ if ( maxScale != 0 && context.rendererScale () > maxScale )
1517
1559
{
1518
1560
return ;
1519
1561
}
0 commit comments