@@ -643,31 +643,28 @@ void QgsComposer::on_mActionExportAsPDF_triggered()
643
643
myQSettings.setValue ( " /UI/lastSaveAtlasAsPdfDir" , outputDir );
644
644
}
645
645
646
- size_t featureI = 0 ;
647
- QPrinter printer;
646
+ mView -> setPaintingEnabled ( false ) ;
647
+
648
648
if ( hasAnAtlas )
649
649
{
650
+ QPrinter printer;
651
+
652
+ QPainter painter;
653
+
650
654
atlasMap->beginRender ();
651
655
if ( atlasOnASingleFile )
652
656
{
653
657
mComposition ->beginPrintAsPDF ( printer, outputFileName );
658
+ painter.begin ( &printer );
654
659
}
655
- }
656
- QPainter painter ( &printer );
657
660
658
- QProgressDialog progress ( tr (" Rendering maps..." ), tr (" Abort" ), 0 , atlasMap->numFeatures (), this );
659
- QApplication::setOverrideCursor ( Qt::BusyCursor );
660
- mView ->setPaintingEnabled ( false );
661
+ QProgressDialog progress ( tr (" Rendering maps..." ), tr (" Abort" ), 0 , atlasMap->numFeatures (), this );
662
+ QApplication::setOverrideCursor ( Qt::BusyCursor );
661
663
662
- do
663
- {
664
- if ( hasAnAtlas )
664
+ for ( size_t featureI = 0 ; featureI < atlasMap->numFeatures (); ++featureI )
665
665
{
666
- if ( 0 == atlasMap->numFeatures () )
667
- break ;
668
-
669
666
progress.setValue ( featureI );
670
- // process input events in order to allow aborting
667
+ // process input events in order to allow aborting
671
668
QCoreApplication::processEvents ();
672
669
if ( progress.wasCanceled () )
673
670
{
@@ -689,30 +686,30 @@ void QgsComposer::on_mActionExportAsPDF_triggered()
689
686
if ( !atlasOnASingleFile )
690
687
{
691
688
outputFileName = QDir (outputDir).filePath ( atlasMap->currentFilename () ) + " .pdf" ;
689
+ mComposition ->beginPrintAsPDF ( printer, outputFileName );
690
+ painter.begin ( &printer );
691
+ mComposition ->doPrint ( printer, painter );
692
+ painter.end ();
692
693
}
693
- }
694
-
695
- if ( !atlasOnASingleFile )
696
- {
697
- mComposition ->exportAsPDF ( outputFileName );
698
- }
699
- else
700
- {
701
- if ( featureI > 0 )
694
+ else
702
695
{
703
- printer.newPage ();
696
+ if ( featureI > 0 )
697
+ {
698
+ printer.newPage ();
699
+ }
700
+ mComposition ->doPrint ( printer, painter );
704
701
}
705
- mComposition ->doPrint ( printer, painter );
706
702
}
707
-
708
- featureI++;
709
- } while ( hasAnAtlas && featureI < atlasMap->numFeatures () );
710
-
711
- if ( hasAnAtlas )
712
- {
713
703
atlasMap->endRender ();
704
+ if ( atlasOnASingleFile )
705
+ {
706
+ painter.end ();
707
+ }
708
+ }
709
+ else
710
+ {
711
+ mComposition ->exportAsPDF ( outputFileName );
714
712
}
715
- painter.end ();
716
713
717
714
mView ->setPaintingEnabled ( true );
718
715
QApplication::restoreOverrideCursor ();
0 commit comments