diff --git a/src/Wt/WContainerWidget.C b/src/Wt/WContainerWidget.C index 7f93ee604..edc782471 100644 --- a/src/Wt/WContainerWidget.C +++ b/src/Wt/WContainerWidget.C @@ -241,6 +241,9 @@ int WContainerWidget::indexOf(WWidget *widget) const WWidget *WContainerWidget::widget(int index) const { + if (index < 0 || index >= children_.size()) + throw Wt::WException("WContainerWidget::widget: index " + std::to_string(index) + + " is out of range [0, " + std::to_string(children_.size()) + ")"); return children_[index]; } diff --git a/src/Wt/WTableView.C b/src/Wt/WTableView.C index c3e1a93fd..bd82aad57 100644 --- a/src/Wt/WTableView.C +++ b/src/Wt/WTableView.C @@ -1315,8 +1315,12 @@ WWidget* WTableView::headerWidget(int column, bool contentsOnly) result = headers_->widget(column - headerColumnsTable_->count()); } } else - if (plainTable_ && column < plainTable_->columnCount()) - result = plainTable_->elementAt(0, column)->widget(0); + if (plainTable_ && column < plainTable_->columnCount()) { + WTableCell *headerCell = plainTable_->elementAt(0, column); + if (headerCell->count() == 0) + return result; + result = headerCell->widget(0); + } if (result && contentsOnly) return result->find("contents");