Skip to content

Commit 154bb2f

Browse files
author
timlinux
committed
Fix for ticket #1149. At times the current row can be returned as -1 which will cause a crash if you try to fetch its display role.
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@8754 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 93a0708 commit 154bb2f

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/app/qgsattributetable.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,8 +358,15 @@ void QgsAttributeTable::contextMenuEvent(QContextMenuEvent *event)
358358
mActionValues.clear();
359359

360360
for (int i = 0; i < columnCount(); ++i)
361-
mActionValues.push_back(std::make_pair(horizontalHeaderItem(i)->text(), item(row, i)->text()));
362-
361+
{
362+
if (row >= 0) //prevent crash if row is negative, see ticket #1149
363+
{
364+
mActionValues.push_back(
365+
std::make_pair(
366+
horizontalHeaderItem( i )->text(),
367+
item( row, i )->text() ) );
368+
}
369+
}
363370
// The item that was clicked on, stored as an index into the
364371
// mActionValues vector.
365372
mClickedOnValue = col;

0 commit comments

Comments
 (0)