@@ -568,9 +568,8 @@ void QgsGrassEdit::setAttributeTable( int field )
568
568
{
569
569
mAttributeTable ->setRowCount ( 0 );
570
570
571
- QString *key = mProvider ->key ( field );
572
-
573
- if ( !key->isEmpty () ) // Database link defined
571
+ QString key = mProvider ->key ( field );
572
+ if ( !key.isEmpty () ) // Database link defined
574
573
{
575
574
QVector<QgsField> *cols = mProvider ->columns ( field );
576
575
@@ -596,6 +595,8 @@ void QgsGrassEdit::setAttributeTable( int field )
596
595
ti->setFlags ( ti->flags () & ~Qt::ItemIsEnabled );
597
596
mAttributeTable ->setItem ( c, 2 , ti );
598
597
}
598
+
599
+ delete cols;
599
600
}
600
601
else
601
602
{
@@ -687,11 +688,10 @@ void QgsGrassEdit::alterTable( void )
687
688
}
688
689
}
689
690
690
- QString *error = mProvider ->createTable ( field, mAttributeTable ->item ( 0 , 0 )->text (), sql );
691
-
692
- if ( !error->isEmpty () )
691
+ QString error = mProvider ->createTable ( field, mAttributeTable ->item ( 0 , 0 )->text (), sql );
692
+ if ( !error.isEmpty () )
693
693
{
694
- QMessageBox::warning ( 0 , tr ( " Warning" ), * error );
694
+ QMessageBox::warning ( 0 , tr ( " Warning" ), error );
695
695
}
696
696
else
697
697
{
@@ -700,7 +700,6 @@ void QgsGrassEdit::alterTable( void )
700
700
str.sprintf ( " %d" , field );
701
701
mFieldBox ->addItem ( str );
702
702
}
703
- delete error;
704
703
}
705
704
else
706
705
{
@@ -719,13 +718,11 @@ void QgsGrassEdit::alterTable( void )
719
718
sql.append ( " (" + mAttributeTable ->item ( i, 2 )->text () + " )" );
720
719
}
721
720
722
- QString *error = mProvider ->addColumn ( field, sql );
723
-
724
- if ( !error->isEmpty () )
721
+ QString error = mProvider ->addColumn ( field, sql );
722
+ if ( !error.isEmpty () )
725
723
{
726
- QMessageBox::warning ( 0 , tr ( " Warning" ), * error );
724
+ QMessageBox::warning ( 0 , tr ( " Warning" ), error );
727
725
}
728
- delete error;
729
726
}
730
727
}
731
728
@@ -1084,21 +1081,18 @@ int QgsGrassEdit::writeLine( int type, struct line_pnts *Points )
1084
1081
Vect_cat_set ( mCats , field, cat );
1085
1082
1086
1083
// Insert new DB record if link is defined and the record for this cat does not exist
1087
- QString *key = mProvider ->key ( field );
1088
-
1089
- if ( !key->isEmpty () ) // Database link defined
1084
+ QString key = mProvider ->key ( field );
1085
+ if ( !key.isEmpty () ) // Database link defined
1090
1086
{
1091
1087
QgsAttributeMap *atts = mProvider ->attributes ( field, cat );
1092
1088
1093
1089
if ( atts->count () == 0 ) // Nothing selected
1094
1090
{
1095
- QString *error = mProvider ->insertAttributes ( field, cat );
1096
-
1097
- if ( !error->isEmpty () )
1091
+ QString error = mProvider ->insertAttributes ( field, cat );
1092
+ if ( !error.isEmpty () )
1098
1093
{
1099
- QMessageBox::warning ( 0 , tr ( " Warning" ), * error );
1094
+ QMessageBox::warning ( 0 , tr ( " Warning" ), error );
1100
1095
}
1101
- delete error;
1102
1096
}
1103
1097
1104
1098
delete atts;
@@ -1411,14 +1405,15 @@ void QgsGrassEdit::checkOrphan( int field, int cat )
1411
1405
QgsDebugMsg ( QString ( " field = %1 cat = %2" ).arg ( field ).arg ( cat ) );
1412
1406
1413
1407
int orphan;
1414
- QString * error = mProvider ->isOrphan ( field, cat, & orphan );
1408
+ QString error = mProvider ->isOrphan ( field, cat, orphan );
1415
1409
1416
- if ( !error-> isEmpty () )
1410
+ if ( !error. isEmpty () )
1417
1411
{
1418
1412
QMessageBox::warning ( 0 , tr ( " Warning" ),
1419
- tr ( " Cannot check orphan record: %1" ).arg ( * error ) );
1413
+ tr ( " Cannot check orphan record: %1" ).arg ( error ) );
1420
1414
return ;
1421
1415
}
1416
+
1422
1417
if ( !orphan )
1423
1418
return ;
1424
1419
@@ -1432,35 +1427,35 @@ void QgsGrassEdit::checkOrphan( int field, int cat )
1432
1427
1433
1428
// Delete record
1434
1429
error = mProvider ->deleteAttribute ( field, cat );
1435
- if ( !error-> isEmpty () )
1430
+ if ( !error. isEmpty () )
1436
1431
{
1437
1432
QMessageBox::warning ( 0 , tr ( " Warning" ), tr ( " Cannot delete orphan record: " )
1438
- + * error );
1433
+ + error );
1439
1434
return ;
1440
1435
}
1441
1436
}
1442
1437
1443
1438
void QgsGrassEdit::addAttributes ( int field, int cat )
1444
1439
{
1445
- QString * key = mProvider ->key ( field );
1440
+ QString key = mProvider ->key ( field );
1446
1441
1447
1442
QString lab;
1448
1443
lab.sprintf ( " %d:%d" , field, cat );
1449
1444
int tab = mAttributes ->addTab ( lab );
1450
1445
mAttributes ->setField ( tab, field );
1451
1446
1452
1447
QString catLabel;
1453
- if ( key-> isEmpty () )
1448
+ if ( key. isEmpty () )
1454
1449
{
1455
1450
catLabel = " Category" ;
1456
1451
}
1457
1452
else
1458
1453
{
1459
- catLabel = * key;
1454
+ catLabel = key;
1460
1455
}
1461
1456
mAttributes ->setCat ( tab, catLabel, cat );
1462
1457
1463
- if ( !key-> isEmpty () ) // Database link defined
1458
+ if ( !key. isEmpty () ) // Database link defined
1464
1459
{
1465
1460
QVector<QgsField> *cols = mProvider ->columns ( field );
1466
1461
@@ -1486,7 +1481,7 @@ void QgsGrassEdit::addAttributes( int field, int cat )
1486
1481
QVariant att = ( *atts )[j];
1487
1482
QgsDebugMsg ( QString ( " name = %1" ).arg ( col.name () ) );
1488
1483
1489
- if ( col.name () != * key )
1484
+ if ( col.name () != key )
1490
1485
{
1491
1486
QgsDebugMsg ( QString ( " value = %1" ).arg ( att.toString () ) );
1492
1487
mAttributes ->addAttribute ( tab, col.name (), att.toString (), col.typeName () );
@@ -1519,21 +1514,18 @@ void QgsGrassEdit::addCat( int line )
1519
1514
increaseMaxCat ();
1520
1515
1521
1516
// Insert new DB record if link is defined and the record for this cat does not exist
1522
- QString *key = mProvider ->key ( field );
1523
-
1524
- if ( !key->isEmpty () ) // Database link defined
1517
+ QString key = mProvider ->key ( field );
1518
+ if ( !key.isEmpty () ) // Database link defined
1525
1519
{
1526
1520
QgsAttributeMap *atts = mProvider ->attributes ( field, cat );
1527
1521
1528
1522
if ( atts->size () == 0 ) // Nothing selected
1529
1523
{
1530
- QString *error = mProvider ->insertAttributes ( field, cat );
1531
-
1532
- if ( !error->isEmpty () )
1524
+ QString error = mProvider ->insertAttributes ( field, cat );
1525
+ if ( !error.isEmpty () )
1533
1526
{
1534
- QMessageBox::warning ( 0 , tr ( " Warning" ), * error );
1527
+ QMessageBox::warning ( 0 , tr ( " Warning" ), error );
1535
1528
}
1536
- delete error;
1537
1529
}
1538
1530
1539
1531
delete atts;
0 commit comments