Skip to content
Permalink
Browse files

[layouts] Fix memory of "force vector" export setting

(cherry picked from commit bbb876d)
  • Loading branch information
nyalldawson committed Dec 11, 2018
1 parent 395dbb2 commit ff912c7ae713a06ed0dbc80b6072fedeb888c572
Showing with 12 additions and 8 deletions.
  1. +12 −8 src/app/layout/qgslayoutdesignerdialog.cpp
@@ -3971,7 +3971,7 @@ bool QgsLayoutDesignerDialog::getSvgExportSettings( QgsLayoutExporter::SvgExport
double marginRight = 0.0;
double marginBottom = 0.0;
double marginLeft = 0.0;
bool previousForceVector = false;
bool forceVector = false;
bool layersAsGroup = false;
bool cropToContents = false;
double topMargin = 0.0;
@@ -3981,7 +3981,7 @@ bool QgsLayoutDesignerDialog::getSvgExportSettings( QgsLayoutExporter::SvgExport
bool includeMetadata = true;
if ( mLayout )
{
mLayout->customProperty( QStringLiteral( "forceVector" ), false ).toBool();
forceVector = mLayout->customProperty( QStringLiteral( "forceVector" ), false ).toBool();
layersAsGroup = mLayout->customProperty( QStringLiteral( "svgGroupLayers" ), false ).toBool();
cropToContents = mLayout->customProperty( QStringLiteral( "svgCropToContents" ), false ).toBool();
topMargin = mLayout->customProperty( QStringLiteral( "svgCropMarginTop" ), 0 ).toInt();
@@ -4008,7 +4008,7 @@ bool QgsLayoutDesignerDialog::getSvgExportSettings( QgsLayoutExporter::SvgExport
options.mTextRenderFormatComboBox->setCurrentIndex( options.mTextRenderFormatComboBox->findData( prevTextRenderFormat ) );
options.chkMapLayersAsGroup->setChecked( layersAsGroup );
options.mClipToContentGroupBox->setChecked( cropToContents );
options.mForceVectorCheckBox->setChecked( previousForceVector );
options.mForceVectorCheckBox->setChecked( forceVector );
options.mTopMarginSpinBox->setValue( topMargin );
options.mRightMarginSpinBox->setValue( rightMargin );
options.mBottomMarginSpinBox->setValue( bottomMargin );
@@ -4025,6 +4025,7 @@ bool QgsLayoutDesignerDialog::getSvgExportSettings( QgsLayoutExporter::SvgExport
marginBottom = options.mBottomMarginSpinBox->value();
marginLeft = options.mLeftMarginSpinBox->value();
includeMetadata = options.mIncludeMetadataCheckbox->isChecked();
forceVector = options.mForceVectorCheckBox->isChecked();
QgsRenderContext::TextRenderFormat textRenderFormat = static_cast< QgsRenderContext::TextRenderFormat >( options.mTextRenderFormatComboBox->currentData().toInt() );

if ( mLayout )
@@ -4037,12 +4038,13 @@ bool QgsLayoutDesignerDialog::getSvgExportSettings( QgsLayoutExporter::SvgExport
mLayout->setCustomProperty( QStringLiteral( "svgCropMarginBottom" ), marginBottom );
mLayout->setCustomProperty( QStringLiteral( "svgCropMarginLeft" ), marginLeft );
mLayout->setCustomProperty( QStringLiteral( "svgIncludeMetadata" ), includeMetadata ? 1 : 0 );
mLayout->setCustomProperty( QStringLiteral( "forceVector" ), forceVector ? 1 : 0 );
mLayout->setCustomProperty( QStringLiteral( "svgTextFormat" ), static_cast< int >( textRenderFormat ) );
}

settings.cropToContents = clipToContent;
settings.cropMargins = QgsMargins( marginLeft, marginTop, marginRight, marginBottom );
settings.forceVectorOutput = options.mForceVectorCheckBox->isChecked();
settings.forceVectorOutput = forceVector;
settings.exportAsLayers = groupLayers;
settings.exportMetadata = includeMetadata;
settings.textRenderFormat = textRenderFormat;
@@ -4053,11 +4055,11 @@ bool QgsLayoutDesignerDialog::getSvgExportSettings( QgsLayoutExporter::SvgExport
bool QgsLayoutDesignerDialog::getPdfExportSettings( QgsLayoutExporter::PdfExportSettings &settings )
{
QgsRenderContext::TextRenderFormat prevTextRenderFormat = mMasterLayout->layoutProject()->labelingEngineSettings().defaultTextRenderFormat();
bool previousForceVector = false;
bool forceVector = false;
bool includeMetadata = true;
if ( mLayout )
{
mLayout->customProperty( QStringLiteral( "forceVector" ), false ).toBool();
forceVector = mLayout->customProperty( QStringLiteral( "forceVector" ), 0 ).toBool();
includeMetadata = mLayout->customProperty( QStringLiteral( "pdfIncludeMetadata" ), 1 ).toBool();
const int prevLayoutSettingLabelsAsOutlines = mLayout->customProperty( QStringLiteral( "pdfTextFormat" ), -1 ).toInt();
if ( prevLayoutSettingLabelsAsOutlines >= 0 )
@@ -4076,23 +4078,25 @@ bool QgsLayoutDesignerDialog::getPdfExportSettings( QgsLayoutExporter::PdfExport
options.mTextRenderFormatComboBox->addItem( tr( "Always Export Text as Text Objects" ), QgsRenderContext::TextFormatAlwaysText );

options.mTextRenderFormatComboBox->setCurrentIndex( options.mTextRenderFormatComboBox->findData( prevTextRenderFormat ) );
options.mForceVectorCheckBox->setChecked( previousForceVector );
options.mForceVectorCheckBox->setChecked( forceVector );
options.mIncludeMetadataCheckbox->setChecked( includeMetadata );

if ( dialog.exec() != QDialog::Accepted )
return false;

includeMetadata = options.mIncludeMetadataCheckbox->isChecked();
forceVector = options.mForceVectorCheckBox->isChecked();
QgsRenderContext::TextRenderFormat textRenderFormat = static_cast< QgsRenderContext::TextRenderFormat >( options.mTextRenderFormatComboBox->currentData().toInt() );

if ( mLayout )
{
//save dialog settings
mLayout->setCustomProperty( QStringLiteral( "forceVector" ), forceVector ? 1 : 0 );
mLayout->setCustomProperty( QStringLiteral( "pdfIncludeMetadata" ), includeMetadata ? 1 : 0 );
mLayout->setCustomProperty( QStringLiteral( "pdfTextFormat" ), static_cast< int >( textRenderFormat ) );
}

settings.forceVectorOutput = options.mForceVectorCheckBox->isChecked();
settings.forceVectorOutput = forceVector;
settings.exportMetadata = includeMetadata;
settings.textRenderFormat = textRenderFormat;

0 comments on commit ff912c7

Please sign in to comment.
You can’t perform that action at this time.