diff --git a/escher/src/table_view.cpp b/escher/src/table_view.cpp index b98bc909a..f4c72317e 100644 --- a/escher/src/table_view.cpp +++ b/escher/src/table_view.cpp @@ -34,8 +34,23 @@ const char * TableView::className() const { #endif void TableView::layoutSubviews(bool force) { - // We force the layoutSubviews in case the frame did not change. - ScrollView::layoutSubviews(true); + /* On the one hand, ScrollView::layoutSubviews() + * calls setFrame(...) over m_contentView, + * which typically calls layoutSubviews() over m_contentView. + * However, if the frame happens to be unchanged, + * setFrame(...) does not call layoutSubviews. + * On the other hand, calling only m_contentView.layoutSubviews() + * does not relayout ScrollView when the offset + * or the content's size changes. + * For those reasons, we call both of them explicitly. + * Besides, one must call layoutSubviews() over + * m_contentView first, in order to reload the table's data, + * otherwise the table's size might be miscomputed... + * FIXME: + * Finally, this solution is not optimal at all since + * layoutSubviews is called twice over m_contentView. */ + m_contentView.layoutSubviews(force); + ScrollView::layoutSubviews(force); } void TableView::reloadCellAtLocation(int i, int j) {