From e79e4cd1920e40620d91e3a141bf9ab559fb87ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Minisini?= Date: Thu, 25 Sep 2008 23:57:06 +0000 Subject: [PATCH] [GB.QT] * BUG: Block events when setting the number of rows and columns in GridView. That prevents some bad crashes. git-svn-id: svn://localhost/gambas/trunk@1602 867c0c6c-44f3-4631-809d-bfa615b0a4ec --- gb.qt/src/CGridView.cpp | 43 +++++++++-------------------------------- gb.qt/src/CGridView.h | 2 +- 2 files changed, 10 insertions(+), 35 deletions(-) diff --git a/gb.qt/src/CGridView.cpp b/gb.qt/src/CGridView.cpp index 137e266db..8451b6407 100644 --- a/gb.qt/src/CGridView.cpp +++ b/gb.qt/src/CGridView.cpp @@ -429,6 +429,7 @@ void MyTable::setNumCols(int newCols) { int i; int col = numCols(); + bool b; if (newCols < 0) return; @@ -436,22 +437,10 @@ void MyTable::setNumCols(int newCols) _cols = newCols; _item->invalidate(); - /* - if (_items) - { - delete[] _items; - _items = (MyTableItem **)0; - } - - if (_cols > 0) - { - _items = new (MyTableItem *)[_cols]; - for (i = 0; i < _cols; i++) - _items[i] = new MyTableItem(this); - } - */ - + b = signalsBlocked(); + blockSignals(true); QTable::setNumCols(newCols); + blockSignals(b); _last_col_width = 0; @@ -472,33 +461,19 @@ void MyTable::setNumCols(int newCols) void MyTable::setNumRows(int newRows) { - //int i; - //int row = numRows(); - - //bool r = verticalHeader()->isResizeEnabled(); - - //setLeftMargin(fontMetrics().width(QString::number(newRows) + "W")); - //verticalHeader()->setResizeEnabled(false); + bool b; if (newRows < 0) return; _rows = newRows; _item->invalidate(); + + b = signalsBlocked(); + blockSignals(true); QTable::setNumRows(newRows); + blockSignals(false); - //verticalHeader()->setResizeEnabled(r); - - /*if (newRows > row) - { - bool upd = verticalHeader()->isUpdatesEnabled(); - verticalHeader()->setUpdatesEnabled(false); - - for (i = row; i < newRows; i++) - verticalHeader()->setLabel(i, QString::number(i + 1)); - - verticalHeader()->setUpdatesEnabled(upd); - }*/ clearSelection(); emit currentChanged(-1, -1); } diff --git a/gb.qt/src/CGridView.h b/gb.qt/src/CGridView.h index 457fc343d..bfa675b88 100644 --- a/gb.qt/src/CGridView.h +++ b/gb.qt/src/CGridView.h @@ -160,7 +160,7 @@ public: int findSelection(int row); void moveItem(int srow, int scol, int drow, int dcol) { _item->move(srow, scol, drow, dcol); } - + public slots: virtual void setNumCols(int);