Skip to content

Commit c55115b

Browse files
author
mhugent
committed
Fix for problems with unique value dialog and some postgis tables
git-svn-id: http://svn.osgeo.org/qgis/trunk@7138 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent a7c8e4f commit c55115b

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/app/qgsuniquevaluedialog.cpp

+13-2
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,19 @@ void QgsUniqueValueDialog::apply()
119119
renderer->insertValue(it->first,newsymbol);
120120
}
121121

122-
renderer->setClassificationField(mClassificationComboBox->currentItem());
123-
mVectorLayer->setRenderer(renderer);
122+
QgsVectorDataProvider *provider = dynamic_cast<QgsVectorDataProvider *>(mVectorLayer->getDataProvider());
123+
if (provider)
124+
{
125+
int fieldIndex = provider->indexFromFieldName(mClassificationComboBox->currentText());
126+
if(fieldIndex > 0)
127+
{
128+
renderer->setClassificationField(fieldIndex);
129+
mVectorLayer->setRenderer(renderer);
130+
return;
131+
}
132+
}
133+
134+
delete renderer; //something went wrong
124135
}
125136

126137
void QgsUniqueValueDialog::changeClassificationAttribute()

src/providers/postgres/qgspostgresprovider.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -1178,6 +1178,9 @@ int QgsPostgresProvider::SRCFromViewColumn(const QString& ns, const QString& rel
11781178

11791179
//relation is table, we just have to add the type
11801180
QString typeSql = "SELECT pg_type.typname FROM pg_attribute, pg_class, pg_namespace, pg_type WHERE pg_class.relname = '" + relname + "' AND pg_namespace.nspname = '" + ns + "' AND pg_attribute.attname = '" + attname_table + "' AND pg_attribute.attrelid = pg_class.oid AND pg_class.relnamespace = pg_namespace.oid AND pg_attribute.atttypid = pg_type.oid";
1181+
QgsDebugMsg("***********************************************************************************");
1182+
QgsDebugMsg(typeSql);
1183+
QgsDebugMsg("***********************************************************************************");
11811184
PGresult* typeSqlResult = PQexec(connection, (const char*)(typeSql.utf8()));
11821185
if(PQntuples(typeSqlResult) < 1)
11831186
{

0 commit comments

Comments
 (0)