@@ -768,6 +768,13 @@ void QgsPalLayerSettings::readDataDefinedProperty( QgsVectorLayer* layer,
768768 bufferDraw = true ;
769769 layer->setCustomProperty ( " labeling/bufferDraw" , true );
770770 }
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+ }
771778 }
772779
773780 // remove old-style field index-based property
@@ -853,7 +860,7 @@ void QgsPalLayerSettings::readFromLayer( QgsVectorLayer* layer )
853860 // text buffer
854861 double bufSize = layer->customProperty ( " labeling/bufferSize" , QVariant ( 0.0 ) ).toDouble ();
855862
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)
857864 QVariant drawBuffer = layer->customProperty ( " labeling/bufferDraw" , QVariant () );
858865 if ( drawBuffer.isValid () )
859866 {
@@ -937,9 +944,30 @@ void QgsPalLayerSettings::readFromLayer( QgsVectorLayer* layer )
937944 priority = layer->customProperty ( " labeling/priority" ).toInt ();
938945
939946 // 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+
943971 fontLimitPixelSize = layer->customProperty ( " labeling/fontLimitPixelSize" , QVariant ( false ) ).toBool ();
944972 fontMinPixelSize = layer->customProperty ( " labeling/fontMinPixelSize" , QVariant ( 0 ) ).toInt ();
945973 fontMaxPixelSize = layer->customProperty ( " labeling/fontMaxPixelSize" , QVariant ( 10000 ) ).toInt ();
@@ -1496,7 +1524,14 @@ void QgsPalLayerSettings::registerFeature( QgsVectorLayer* layer, QgsFeature& f
14961524 minScale = mins;
14971525 }
14981526 }
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 )
15001535 {
15011536 return ;
15021537 }
@@ -1513,7 +1548,14 @@ void QgsPalLayerSettings::registerFeature( QgsVectorLayer* layer, QgsFeature& f
15131548 maxScale = maxs;
15141549 }
15151550 }
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 )
15171559 {
15181560 return ;
15191561 }
0 commit comments