Skip to content
Permalink
Browse files

Make renderFeature method virtual. More safety checks in the renderer…

… props dialog

git-svn-id: http://svn.osgeo.org/qgis/trunk@13135 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent
mhugent committed Mar 21, 2010
1 parent 1d056de commit 40ba1101057490507fed347bba0d5003e498094d
Showing with 17 additions and 11 deletions.
  1. +1 −1 src/core/symbology-ng/qgsrendererv2.h
  2. +16 −10 src/gui/symbology-ng/qgsrendererv2propertiesdialog.cpp
@@ -73,7 +73,7 @@ class CORE_EXPORT QgsFeatureRendererV2

virtual QgsFeatureRendererV2* clone() = 0;

void renderFeature( QgsFeature& feature, QgsRenderContext& context, int layer = -1, bool drawVertexMarker = false );
virtual void renderFeature( QgsFeature& feature, QgsRenderContext& context, int layer = -1, bool drawVertexMarker = false );

//! for debugging
virtual QString dump();
@@ -18,31 +18,31 @@
#include <QKeyEvent>
#include <QMessageBox>

static bool _initRenderer(QString name, QgsRendererV2WidgetFunc f, QString iconName )
static bool _initRenderer( QString name, QgsRendererV2WidgetFunc f, QString iconName )
{
QgsRendererV2Registry* reg = QgsRendererV2Registry::instance();
QgsRendererV2AbstractMetadata* am = reg->rendererMetadata( name );
if (am == NULL)
if ( am == NULL )
return false;
QgsRendererV2Metadata* m = dynamic_cast<QgsRendererV2Metadata*>(am);
if (m == NULL)
QgsRendererV2Metadata* m = dynamic_cast<QgsRendererV2Metadata*>( am );
if ( m == NULL )
return false;

m->setWidgetFunction(f);
m->setWidgetFunction( f );

QString iconPath = QgsApplication::defaultThemePath() + iconName;
QPixmap pix;
if ( pix.load( iconPath, "png" ) )
m->setIcon(pix);
m->setIcon( pix );

QgsDebugMsg("Set for "+name);
QgsDebugMsg( "Set for " + name );
return true;
}

static void _initRendererWidgetFunctions()
{
static bool initialized = false;
if (initialized)
if ( initialized )
return;

_initRenderer( "singleSymbol", QgsSingleSymbolRendererV2Widget::create, "rendererSingleSymbol.png" );
@@ -154,9 +154,15 @@ void QgsRendererV2PropertiesDialog::rendererChanged()

void QgsRendererV2PropertiesDialog::apply()
{
if ( mActiveWidget != NULL )
if ( !mActiveWidget || !mLayer )
{
mLayer->setRendererV2( mActiveWidget->renderer()->clone() );
return;
}

QgsFeatureRendererV2* renderer = mActiveWidget->renderer();
if ( renderer )
{
mLayer->setRendererV2( renderer->clone() );
}
}

0 comments on commit 40ba110

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