From 30c9aa0315d7b61fe054f21b8e7d0106fd24ee34 Mon Sep 17 00:00:00 2001 From: timlinux Date: Fri, 11 Jul 2008 17:54:28 +0000 Subject: [PATCH] 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@8754 c8812cc2-4d05-0410-92ff-de0c093fc19c --- src/app/qgsattributetable.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/app/qgsattributetable.cpp b/src/app/qgsattributetable.cpp index af32df57ac4..74656bb1619 100644 --- a/src/app/qgsattributetable.cpp +++ b/src/app/qgsattributetable.cpp @@ -358,8 +358,15 @@ void QgsAttributeTable::contextMenuEvent(QContextMenuEvent *event) mActionValues.clear(); for (int i = 0; i < columnCount(); ++i) - mActionValues.push_back(std::make_pair(horizontalHeaderItem(i)->text(), item(row, i)->text())); - + { + if (row >= 0) //prevent crash if row is negative, see ticket #1149 + { + mActionValues.push_back( + std::make_pair( + horizontalHeaderItem( i )->text(), + item( row, i )->text() ) ); + } + } // The item that was clicked on, stored as an index into the // mActionValues vector. mClickedOnValue = col;