Fix layout picture item test (alternate fix to #31382) (#31383)

* Fix layout picture item test (alternate fix to #31382)
* doxygen: add pointer to QgsProperty::value() to QgsAbstractPropertyCollection::value()
This commit is contained in:
Jürgen Fischer 2019-08-24 23:49:22 +02:00 committed by GitHub
parent a90bee24a4
commit 596ffd06fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 11 additions and 3 deletions

View File

@ -89,6 +89,8 @@ Returns a matching property from the collection, if one exists.
virtual QVariant value( int key, const QgsExpressionContext &context, const QVariant &defaultValue = QVariant() ) const = 0;
%Docstring
Returns the calculated value of the property with the specified key from within the collection.
If you need the validity of the value (like ok provided from the
valueAs* variants) refer to the property() and :py:func:`QgsProperty.value()`
:param key: integer key for property to return. The intended use case is that a context specific enum is cast to
int and used for the key value.

View File

@ -342,8 +342,10 @@ void QgsLayoutItemPicture::refreshPicture( const QgsExpressionContext *context )
mHasExpressionError = false;
if ( mDataDefinedProperties.isActive( QgsLayoutObject::PictureSource ) )
{
source = mDataDefinedProperties.value( QgsLayoutObject::PictureSource, *evalContext, QVariant( source ) );
if ( !source.canConvert( QMetaType::QString ) )
bool ok = false;
const QgsProperty &sourceProperty = mDataDefinedProperties.property( QgsLayoutObject::PictureSource );
source = sourceProperty.value( *evalContext, QVariant( source ), &ok );
if ( !ok || !source.canConvert( QMetaType::QString ) )
{
mHasExpressionError = true;
source = QString();

View File

@ -101,6 +101,8 @@ class CORE_EXPORT QgsAbstractPropertyCollection
/**
* Returns the calculated value of the property with the specified key from within the collection.
* If you need the validity of the value (like ok provided from the
* valueAs* variants) refer to the property() and QgsProperty::value()
* \param key integer key for property to return. The intended use case is that a context specific enum is cast to
* int and used for the key value.
* \param context expression context to evaluate property against

View File

@ -60,7 +60,8 @@ MACRO (ADD_QGIS_TEST TESTSRC)
STRING(REPLACE "qgs" "" TESTNAME ${TESTNAME})
STRING(REPLACE ".cpp" "" TESTNAME ${TESTNAME})
SET (TESTNAME "qgis_${TESTNAME}test")
ADD_EXECUTABLE(${TESTNAME} ${TESTSRC} ${util_SRCS})
QT5_ADD_RESOURCES(IMAGES_RCC_SRC ${CMAKE_SOURCE_DIR}/images/images.qrc)
ADD_EXECUTABLE(${TESTNAME} ${TESTSRC} ${util_SRCS} ${IMAGES_RCC_SRC})
SET_TARGET_PROPERTIES(${TESTNAME} PROPERTIES AUTOMOC TRUE)
TARGET_LINK_LIBRARIES(${TESTNAME}
${Qt5Core_LIBRARIES}

View File

@ -76,6 +76,7 @@ void TestQgsLayoutPicture::initTestCase()
{
QgsApplication::init();
QgsApplication::initQgis();
QgsApplication::showSettings();
mPngImage = QStringLiteral( TEST_DATA_DIR ) + "/sample_image.png";
mSvgImage = QStringLiteral( TEST_DATA_DIR ) + "/sample_svg.svg";

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 32 KiB