Skip to content

Commit 25b2f95

Browse files
author
wonder
committed
Make sure we have a color ramp when creating categories/ranges.
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@12160 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent a5658a3 commit 25b2f95

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/gui/symbology-ng/qgscategorizedsymbolrendererv2widget.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "qgsvectorlayer.h"
1313
#include "qgsvectordataprovider.h" // for uniqueValues
1414

15+
#include <QMessageBox>
1516
#include <QStandardItemModel>
1617
#include <QStandardItem>
1718

@@ -256,6 +257,15 @@ void QgsCategorizedSymbolRendererV2Widget::addCategories()
256257
else
257258
ramp = mStyle->colorRamp( rampName );
258259

260+
if ( ramp == NULL )
261+
{
262+
if ( cboCategorizedColorRamp->count() == 0 )
263+
QMessageBox::critical( this, tr("Error"), tr("There are no available color ramps. You can add them in Style Manager.") );
264+
else
265+
QMessageBox::critical( this, tr("Error"), tr("The selected color ramp is not available.") );
266+
return;
267+
}
268+
259269
QgsCategoryList cats;
260270
_createCategories( cats, unique_vals, mCategorizedSymbol, ramp );
261271

src/gui/symbology-ng/qgsgraduatedsymbolrendererv2widget.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
#include "qgssymbolv2selectordialog.h"
1313

14+
#include <QMessageBox>
1415
#include <QStandardItemModel>
1516
#include <QStandardItem>
1617

@@ -157,6 +158,15 @@ void QgsGraduatedSymbolRendererV2Widget::classifyGraduated()
157158
else
158159
ramp = mStyle->colorRamp( rampName );
159160

161+
if ( ramp == NULL )
162+
{
163+
if ( cboGraduatedColorRamp->count() == 0 )
164+
QMessageBox::critical( this, tr("Error"), tr("There are no available color ramps. You can add them in Style Manager.") );
165+
else
166+
QMessageBox::critical( this, tr("Error"), tr("The selected color ramp is not available.") );
167+
return;
168+
}
169+
160170
QgsGraduatedSymbolRendererV2::Mode mode;
161171
if (cboGraduatedMode->currentIndex() == 0)
162172
mode = QgsGraduatedSymbolRendererV2::EqualInterval;

0 commit comments

Comments
 (0)