From ca9fa09fd8451555dce6165f845e55c674f632da Mon Sep 17 00:00:00 2001 From: Jorge Moraleda Date: Tue, 29 Dec 2020 18:58:05 -0800 Subject: [PATCH] Fix drawing expander column without values in generic wxDVC When an item is marked as not containing any value in the expander column, we must still draw the expander button if it has children, so skip only drawing the item value in this case (and also preparing it for drawing it, as calling PrepareForItem() would trigger an assert failure for the items without value), but still execute the rest of the drawing code for it, including drawing the background and expander button. Closes https://github.com/wxWidgets/wxWidgets/pull/2144 --- src/generic/datavgen.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/generic/datavgen.cpp b/src/generic/datavgen.cpp index 04536117bf..395403dd0f 100644 --- a/src/generic/datavgen.cpp +++ b/src/generic/datavgen.cpp @@ -2790,6 +2790,7 @@ void wxDataViewMainWindow::OnPaint( wxPaintEvent &WXUNUSED(event) ) wxDataViewTreeNode *node = NULL; wxDataViewItem dataitem; const int line_height = GetLineHeight(item); + bool hasValue = true; if (!IsVirtualList()) { @@ -2802,12 +2803,9 @@ void wxDataViewMainWindow::OnPaint( wxPaintEvent &WXUNUSED(event) ) dataitem = node->GetItem(); - // Skip al columns that do not have values if ( !model->HasValue(dataitem, col->GetModelColumn()) ) - { - cell_rect.y += line_height; - continue; - } + hasValue = false; + } else { @@ -2824,7 +2822,8 @@ void wxDataViewMainWindow::OnPaint( wxPaintEvent &WXUNUSED(event) ) state |= wxDATAVIEW_CELL_SELECTED; cell->SetState(state); - cell->PrepareForItem(model, dataitem, col->GetModelColumn()); + if (hasValue) + cell->PrepareForItem(model, dataitem, col->GetModelColumn()); // draw the background if ( !selected ) @@ -2905,7 +2904,8 @@ void wxDataViewMainWindow::OnPaint( wxPaintEvent &WXUNUSED(event) ) // make its own renderer and thus we cannot be sure of that. wxDCClipper clip(dc, item_rect); - cell->WXCallRender(item_rect, &dc, state); + if (hasValue) + cell->WXCallRender(item_rect, &dc, state); cell_rect.y += line_height; }