Skip to content

Commit

Permalink
Fix API break of QgsMapLayer class introduced in 2.16
Browse files Browse the repository at this point in the history
This breakage was resulting in a Python error when using plugin layers
due to calls to pure virtual method writeStyle()
  • Loading branch information
wonder-sk committed Jun 22, 2016
1 parent b040410 commit 8fcac87
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 6 deletions.
12 changes: 9 additions & 3 deletions python/core/qgsmaplayer.sip
Original file line number Diff line number Diff line change
Expand Up @@ -462,8 +462,10 @@ class QgsMapLayer : QObject
* @param node node that will contain the style definition for this layer.
* @param errorMessage reference to string that will be updated with any error messages
* @return true in case of success.
* @note added in 2.16
* @note To be implemented in subclasses. Default implementation does nothing and returns false.
*/
virtual bool readStyle( const QDomNode& node, QString& errorMessage ) = 0;
virtual bool readStyle( const QDomNode& node, QString& errorMessage );

/** Write the symbology for the layer into the docment provided.
* @param node the node that will have the style element added to it.
Expand All @@ -478,13 +480,17 @@ class QgsMapLayer : QObject
* @param doc the document that will have the QDomNode added.
* @param errorMessage reference to string that will be updated with any error messages
* @return true in case of success.
* @note added in 2.16
* @note To be implemented in subclasses. Default implementation does nothing and returns false.
*/
virtual bool writeStyle( QDomNode& node, QDomDocument& doc, QString& errorMessage ) const = 0;
virtual bool writeStyle( QDomNode& node, QDomDocument& doc, QString& errorMessage ) const;

/** Return pointer to layer's undo stack */
QUndoStack *undoStack();

/** Return pointer to layer's style undo stack */
/** Return pointer to layer's style undo stack
* @note added in 2.16
*/
QUndoStack *undoStackStyles();

/* Layer legendUrl information */
Expand Down
15 changes: 15 additions & 0 deletions src/core/qgsmaplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1609,6 +1609,21 @@ QString QgsMapLayer::loadSldStyle( const QString &theURI, bool &theResultFlag )
return "";
}

bool QgsMapLayer::readStyle( const QDomNode& node, QString& errorMessage )
{
Q_UNUSED( node );
Q_UNUSED( errorMessage );
return false;
}

bool QgsMapLayer::writeStyle( QDomNode& node, QDomDocument& doc, QString& errorMessage ) const
{
Q_UNUSED( node );
Q_UNUSED( doc );
Q_UNUSED( errorMessage );
return false;
}


QUndoStack* QgsMapLayer::undoStack()
{
Expand Down
12 changes: 9 additions & 3 deletions src/core/qgsmaplayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -482,8 +482,10 @@ class CORE_EXPORT QgsMapLayer : public QObject
* @param node node that will contain the style definition for this layer.
* @param errorMessage reference to string that will be updated with any error messages
* @return true in case of success.
* @note added in 2.16
* @note To be implemented in subclasses. Default implementation does nothing and returns false.
*/
virtual bool readStyle( const QDomNode& node, QString& errorMessage ) = 0;
virtual bool readStyle( const QDomNode& node, QString& errorMessage );

/** Write the symbology for the layer into the docment provided.
* @param node the node that will have the style element added to it.
Expand All @@ -498,13 +500,17 @@ class CORE_EXPORT QgsMapLayer : public QObject
* @param doc the document that will have the QDomNode added.
* @param errorMessage reference to string that will be updated with any error messages
* @return true in case of success.
* @note added in 2.16
* @note To be implemented in subclasses. Default implementation does nothing and returns false.
*/
virtual bool writeStyle( QDomNode& node, QDomDocument& doc, QString& errorMessage ) const = 0;
virtual bool writeStyle( QDomNode& node, QDomDocument& doc, QString& errorMessage ) const;

/** Return pointer to layer's undo stack */
QUndoStack *undoStack();

/** Return pointer to layer's style undo stack */
/** Return pointer to layer's style undo stack
* @note added in 2.16
*/
QUndoStack *undoStackStyles();

/* Layer legendUrl information */
Expand Down

1 comment on commit 8fcac87

@NathanW2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry about that. Thanks for the fix.

Please sign in to comment.