Fixed bug: check widget type before casting it.

git-svn-id: http://yate.null.ro/svn/yate/trunk@3400 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
marian 2010-06-25 07:48:41 +00:00
parent d45b2bf34d
commit 5f8e3b1ebb
1 changed files with 11 additions and 11 deletions

View File

@ -1456,7 +1456,7 @@ bool QtWindow::addTableRow(const String& name, const String& item,
if (uiw) if (uiw)
return uiw->addTableRow(item,data,atStart); return uiw->addTableRow(item,data,atStart);
// Handle basic QTableWidget // Handle basic QTableWidget
if (!w.table()) if (w.type() != QtWidget::Table)
return false; return false;
TableWidget tbl(w.table()); TableWidget tbl(w.table());
int row = atStart ? 0 : tbl.rowCount(); int row = atStart ? 0 : tbl.rowCount();
@ -1494,9 +1494,9 @@ bool QtWindow::insertTableRow(const String& name, const String& item,
UIWidget* uiw = w.uiWidget(); UIWidget* uiw = w.uiWidget();
if (uiw) if (uiw)
return uiw->insertTableRow(item,before,data); return uiw->insertTableRow(item,before,data);
TableWidget tbl(w.table()); if (w.type() != QtWidget::Table)
if (!tbl.valid())
return false; return false;
TableWidget tbl(w.table());
int row = tbl.getRow(before); int row = tbl.getRow(before);
if (row == -1) if (row == -1)
row = tbl.rowCount(); row = tbl.rowCount();
@ -1577,9 +1577,9 @@ bool QtWindow::setTableRow(const String& name, const String& item, const NamedLi
UIWidget* uiw = w.uiWidget(); UIWidget* uiw = w.uiWidget();
if (uiw) if (uiw)
return uiw->setTableRow(item,data); return uiw->setTableRow(item,data);
TableWidget tbl(w.table()); if (w.type() != QtWidget::Table)
if (!tbl.valid())
return false; return false;
TableWidget tbl(w.table());
int row = tbl.getRow(item); int row = tbl.getRow(item);
if (row < 0) if (row < 0)
return false; return false;
@ -1599,9 +1599,9 @@ bool QtWindow::getTableRow(const String& name, const String& item, NamedList* da
UIWidget* uiw = w.uiWidget(); UIWidget* uiw = w.uiWidget();
if (uiw) if (uiw)
return uiw->getTableRow(item,data); return uiw->getTableRow(item,data);
TableWidget tbl(w.table(),false); if (w.type() != QtWidget::Table)
if (!tbl.valid())
return false; return false;
TableWidget tbl(w.table(),false);
int row = tbl.getRow(item); int row = tbl.getRow(item);
if (row < 0) if (row < 0)
return false; return false;
@ -1671,11 +1671,11 @@ bool QtWindow::updateTableRows(const String& name, const NamedList* data, bool a
raiseSelectIfEmpty(ct->rowCount(),this,name); raiseSelectIfEmpty(ct->rowCount(),this,name);
return ok; return ok;
} }
TableWidget tbl(w.table()); if (w.type() != QtWidget::Table)
if (!tbl.valid())
return false; return false;
if (!data) if (!data)
return true; return true;
TableWidget tbl(w.table());
bool ok = true; bool ok = true;
tbl.table()->setUpdatesEnabled(false); tbl.table()->setUpdatesEnabled(false);
unsigned int n = data->length(); unsigned int n = data->length();
@ -2247,7 +2247,7 @@ bool QtWindow::eventFilter(QObject* obj, QEvent* event)
bool ok = true; bool ok = true;
bool handled = true; bool handled = true;
if (prop == s_propColWidths) { if (prop == s_propColWidths) {
if (w.table()) { if (w.type() == QtWidget::Table) {
ObjList* list = value.split(',',false); ObjList* list = value.split(',',false);
unsigned int col = 0; unsigned int col = 0;
for (ObjList* o = list->skipNull(); o; o = o->skipNext(), col++) { for (ObjList* o = list->skipNull(); o; o = o->skipNext(), col++) {
@ -2259,7 +2259,7 @@ bool QtWindow::eventFilter(QObject* obj, QEvent* event)
} }
} }
else if (prop == s_propSorting) { else if (prop == s_propSorting) {
if (w.table()) { if (w.type() == QtWidget::Table) {
ObjList* list = value.split(',',false); ObjList* list = value.split(',',false);
String* tmp = static_cast<String*>((*list)[0]); String* tmp = static_cast<String*>((*list)[0]);
int col = tmp ? tmp->toInteger(-1) : -1; int col = tmp ? tmp->toInteger(-1) : -1;