Skip to content

Commit fc5ee8d

Browse files
author
mhugent
committed
fix for crash when opening the attribute table for postgis layers after commiting. Added a first version of marker visualisation for line/polygon digitising
git-svn-id: http://svn.osgeo.org/qgis/trunk@5507 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 2e95fe1 commit fc5ee8d

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

src/gui/qgsattributetable.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,11 @@ void QgsAttributeTable::fillTable(QgsVectorLayer* layer)
499499

500500
void QgsAttributeTable::putFeatureInTable(int row, QgsFeature* fet)
501501
{
502+
if(row >= numRows())//prevent a crash if a provider doesn't update the feature count properly
503+
{
504+
setNumRows(row+1);
505+
}
506+
502507
//id-field
503508
int id = fet->featureId();
504509
setText(row, 0, QString::number(id));

src/gui/qgsvectorlayer.cpp

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,6 @@ QgsVectorLayer::~QgsVectorLayer()
182182
delete (*it).second;
183183
}
184184
mCachedGeometries.clear();
185-
186185
}
187186

188187
QString QgsVectorLayer::storageType() const
@@ -502,6 +501,17 @@ unsigned char* QgsVectorLayer::drawLineString(unsigned char* feature,
502501
myTransparentPen.setColor(myColor);
503502
p->setPen(myTransparentPen);
504503
p->drawPolyline(pa);
504+
505+
if(mEditable)
506+
{
507+
std::vector<double>::const_iterator xIt;
508+
std::vector<double>::const_iterator yIt;
509+
for(xIt = x.begin(), yIt = y.begin(); xIt != x.end(); ++xIt, ++yIt)
510+
{
511+
drawVertexMarker((int)(*xIt), (int)(*yIt), *p);
512+
}
513+
}
514+
505515
//restore the pen
506516
p->setPen(pen);
507517

@@ -751,6 +761,14 @@ std::cerr << i << ": " << ring->first[i]
751761
for (; ri != ringDetails.end(); ++ri)
752762
p->drawPolygon(pa.constData() + ri->first, ri->second, Qt::OddEvenFill);
753763

764+
if(mEditable)//draw the vertex markers
765+
{
766+
for(int i = 0; i < pa.size(); ++i)
767+
{
768+
drawVertexMarker((int)(pa[i].x()), (int)(pa[i].y()), *p);
769+
}
770+
}
771+
754772
//
755773
//restore brush and pen to original
756774
//
@@ -940,6 +958,14 @@ void QgsVectorLayer::deleteCachedGeometries()
940958
mCachedGeometries.clear();
941959
}
942960

961+
void QgsVectorLayer::drawVertexMarker(int x, int y, QPainter& p)
962+
{
963+
int size = 15;
964+
int m = (size-1)/2;
965+
p.drawLine(x-m, y+m, x+m, y-m);
966+
p.drawLine(x-m, y-m, x+m, y+m);
967+
}
968+
943969
void QgsVectorLayer::table()
944970
{
945971
if (tabledisplay)
@@ -1848,6 +1874,7 @@ void QgsVectorLayer::startEditing()
18481874
{
18491875
mToggleEditingAction->setChecked(true);
18501876
}
1877+
triggerRepaint();
18511878
}
18521879
}
18531880
}
@@ -1872,6 +1899,7 @@ void QgsVectorLayer::stopEditing()
18721899
else
18731900
{
18741901
dataProvider->updateExtents();
1902+
dataProvider->updateFeatureCount();
18751903
//hide and delete the table because it is not up to date any more
18761904
if (tabledisplay)
18771905
{

src/gui/qgsvectorlayer.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,8 @@ protected slots:
564564
void cacheGeometries();
565565
/**Deletes the geometries in mCachedGeometries*/
566566
void deleteCachedGeometries();
567+
/**Draws a vertex symbol at (screen) coordinates x, y*/
568+
void drawVertexMarker(int x, int y, QPainter& p);
567569

568570
// pointer for loading the provider library
569571
QLibrary *myLib;

0 commit comments

Comments
 (0)