Skip to content
Permalink
Browse files

fix backward compatibility and fix leak

  • Loading branch information
3nids committed May 6, 2020
1 parent 03f4cb9 commit 525661cfe523e3e3a5268ea09d2d47966cb32b9d
Showing with 10 additions and 10 deletions.
  1. +6 −4 src/core/layout/qgscompositionconverter.cpp
  2. +4 −6 src/core/layout/qgslayouttable.cpp
@@ -1428,7 +1428,11 @@ bool QgsCompositionConverter::readTableXml( QgsLayoutItemAttributeTable *layoutI
layoutItem->setWrapBehavior( static_cast<QgsLayoutTable::WrapBehavior>( itemElem.attribute( QStringLiteral( "wrapBehavior" ), QStringLiteral( "0" ) ).toInt() ) );

//restore column specifications
qDeleteAll( layoutItem->mColumns );
layoutItem->mColumns.clear();
qDeleteAll( layoutItem->mSortColumns );
layoutItem->mSortColumns.clear();

QDomNodeList columnsList = itemElem.elementsByTagName( QStringLiteral( "displayColumns" ) );
if ( !columnsList.isEmpty() )
{
@@ -1464,12 +1468,10 @@ bool QgsCompositionConverter::readTableXml( QgsLayoutItemAttributeTable *layoutI
layoutItem->mColumns.append( column );

// sorting columns are now (QGIS 3.14+) handled in a dedicated list
QVector<QgsLayoutTableColumn *> sortColumns;
Q_NOWARN_DEPRECATED_PUSH
std::copy_if( layoutItem->mColumns.begin(), layoutItem->mColumns.end(), std::back_inserter( sortColumns ), []( QgsLayoutTableColumn * col ) {return col->sortByRank() > 0;} );
std::sort( sortColumns.begin(), sortColumns.end(), []( QgsLayoutTableColumn * a, QgsLayoutTableColumn * b ) {return a->sortByRank() < b->sortByRank();} );
std::copy_if( layoutItem->mColumns.begin(), layoutItem->mColumns.end(), std::back_inserter( layoutItem->mSortColumns ), []( QgsLayoutTableColumn * col ) {return col->sortByRank() > 0;} );
std::sort( layoutItem->mSortColumns.begin(), layoutItem->mSortColumns.end(), []( QgsLayoutTableColumn * a, QgsLayoutTableColumn * b ) {return a->sortByRank() < b->sortByRank();} );
Q_NOWARN_DEPRECATED_POP
// TODO remove comment: layoutItem->mSortColumns = sortColumns;
}
}

@@ -180,9 +180,9 @@ bool QgsLayoutTable::readPropertiesFromElement( const QDomElement &itemElem, con
qDeleteAll( mSortColumns );
mSortColumns.clear();
QDomNodeList sortColumnsList = itemElem.elementsByTagName( QStringLiteral( "sortColumns" ) );
if ( !columnsList.isEmpty() )
if ( !sortColumnsList.isEmpty() )
{
QDomElement columnsElem = columnsList.at( 0 ).toElement();
QDomElement columnsElem = sortColumnsList.at( 0 ).toElement();
QDomNodeList columnEntryList = columnsElem.elementsByTagName( QStringLiteral( "column" ) );
for ( int i = 0; i < columnEntryList.size(); ++i )
{
@@ -195,12 +195,10 @@ bool QgsLayoutTable::readPropertiesFromElement( const QDomElement &itemElem, con
else
{
// backward compatibility for QGIS < 3.14
QVector<QgsLayoutTableColumn *> sortColumns;
Q_NOWARN_DEPRECATED_PUSH
std::copy_if( mColumns.begin(), mColumns.end(), std::back_inserter( sortColumns ), []( QgsLayoutTableColumn * col ) {return col->sortByRank() > 0;} );
std::sort( sortColumns.begin(), sortColumns.end(), []( QgsLayoutTableColumn * a, QgsLayoutTableColumn * b ) {return a->sortByRank() < b->sortByRank();} );
std::copy_if( mColumns.begin(), mColumns.end(), std::back_inserter( mSortColumns ), []( QgsLayoutTableColumn * col ) {return col->sortByRank() > 0;} );
std::sort( mSortColumns.begin(), mSortColumns.end(), []( QgsLayoutTableColumn * a, QgsLayoutTableColumn * b ) {return a->sortByRank() < b->sortByRank();} );
Q_NOWARN_DEPRECATED_POP
// TODO remove comment: mSortColumns = sortColumns;
}

//restore cell styles

0 comments on commit 525661c

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