Skip to content
Permalink
Browse files

Remove duplicate QgsRasterLayer constructor

Avoids confusing overload behavior when constructing QgsRasterLayers
from c++ code. This extra constructor was causing character literals
to be converted to a boolean loadDefaultStyle flag instead
of being used as the provider key. Removing the extra constructor
avoids this, and removes some duplicate code.
  • Loading branch information
nyalldawson committed Jan 27, 2017
1 parent d259cdf commit 45fc6dc2fe5acb6b28652287742100d5d6e0066e
@@ -1569,6 +1569,9 @@ QgsRasterInterface {#qgis_api_break_3_0_QgsRasterInterface}
QgsRasterLayer {#qgis_api_break_3_0_QgsRasterLayer}
--------------

- The constructor variant with loadDefaultStyleFlag as the 3rd parameter was removed. Use the
constructor variant which accepts a data provider string and loadDefaultStyleFlag as the
4th parameter instead.
- setDrawingStyle() was removed. Use setRendererForDrawingStyle() or setRenderer() instead.
- previewAsPixmap() was removed. Use previewAsImage() instead.
- updateProgress() had no effect and was removed.
@@ -33,19 +33,9 @@ class QgsRasterLayer : QgsMapLayer
*
* -
* */
QgsRasterLayer( const QString &path,
const QString &baseName = QString::null,
bool loadDefaultStyleFlag = true );

//TODO - QGIS 3.0
//This constructor is confusing if used with string literals for providerKey,
//as the previous constructor will be called with the literal for providerKey
//implicitly converted to a bool.
//for QGIS 3.0, make either constructor explicit or alter the signatures
/** \brief [ data provider interface ] Constructor in provider mode */
QgsRasterLayer( const QString &uri,
const QString &baseName,
const QString &providerKey,
const QString &baseName = QString(),
const QString &providerKey = "gdal",
bool loadDefaultStyleFlag = true );

/** \brief The destructor */
@@ -104,38 +104,6 @@ QgsRasterLayer::QgsRasterLayer()
mValid = false;
}

QgsRasterLayer::QgsRasterLayer(
const QString& path,
const QString& baseName,
bool loadDefaultStyleFlag )
: QgsMapLayer( RasterLayer, baseName, path )
, QSTRING_NOT_SET( QStringLiteral( "Not Set" ) )
, TRSTRING_NOT_SET( tr( "Not Set" ) )
, mDataProvider( nullptr )
{
QgsDebugMsgLevel( "Entered", 4 );

// TODO, call constructor with provider key
init();
setDataProvider( QStringLiteral( "gdal" ) );
if ( !mValid ) return;

bool defaultLoadedFlag = false;
if ( mValid && loadDefaultStyleFlag )
{
loadDefaultStyle( defaultLoadedFlag );
}
if ( !defaultLoadedFlag )
{
setDefaultContrastEnhancement();
}
return;
} // QgsRasterLayer ctor

/**
* @todo Rename into a general constructor when the old raster interface is retired
* parameter dummy is just there to distinguish this function signature from the old non-provider one.
*/
QgsRasterLayer::QgsRasterLayer( const QString & uri,
const QString & baseName,
const QString & providerKey,
@@ -179,19 +179,9 @@ class CORE_EXPORT QgsRasterLayer : public QgsMapLayer
*
* -
* */
QgsRasterLayer( const QString &path,
const QString &baseName = QString::null,
bool loadDefaultStyleFlag = true );

//TODO - QGIS 3.0
//This constructor is confusing if used with string literals for providerKey,
//as the previous constructor will be called with the literal for providerKey
//implicitly converted to a bool.
//for QGIS 3.0, make either constructor explicit or alter the signatures
//! \brief [ data provider interface ] Constructor in provider mode
QgsRasterLayer( const QString &uri,
const QString &baseName,
const QString &providerKey,
const QString &baseName = QString(),
const QString &providerKey = "gdal",
bool loadDefaultStyleFlag = true );

~QgsRasterLayer();

0 comments on commit 45fc6dc

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