diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-08-11 15:12:59 +0100 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2020-08-12 12:03:25 +0200 |
commit | cc36d48b0e8f1aec3f8120db5d249e74587e92fd (patch) | |
tree | 2d039eb093b70701e1b06c0c9dfe29bf9d5d2a59 | |
parent | 227d30a3a17f2fffb1a166cdc3e2a796bb335214 (diff) |
unset CustomCellRenderer instances in dtor
Change-Id: I60a5f91df65d1d511ba863ba9a0286c1483314d2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100513
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
-rw-r--r-- | vcl/unx/gtk3/gtk3gtkinst.cxx | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx index b8f1b66c4b49..c399eaf1a356 100644 --- a/vcl/unx/gtk3/gtk3gtkinst.cxx +++ b/vcl/unx/gtk3/gtk3gtkinst.cxx @@ -5296,6 +5296,7 @@ GType crippled_viewport_get_type() #define CUSTOM_TYPE_CELL_RENDERER_SURFACE (custom_cell_renderer_surface_get_type()) #define CUSTOM_CELL_RENDERER_SURFACE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), CUSTOM_TYPE_CELL_RENDERER_SURFACE, CustomCellRendererSurface)) +#define CUSTOM_IS_CELL_RENDERER_SURFACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CUSTOM_TYPE_CELL_RENDERER_SURFACE)) namespace { @@ -11403,11 +11404,26 @@ public: g_signal_handler_disconnect(m_pTreeView, m_nRowActivatedSignalId); g_signal_handler_disconnect(gtk_tree_view_get_selection(m_pTreeView), m_nChangedSignalId); + GValue value = G_VALUE_INIT; + g_value_init(&value, G_TYPE_POINTER); + g_value_set_pointer(&value, static_cast<gpointer>(nullptr)); + for (GList* pEntry = g_list_last(m_pColumns); pEntry; pEntry = g_list_previous(pEntry)) { GtkTreeViewColumn* pColumn = GTK_TREE_VIEW_COLUMN(pEntry->data); g_signal_handler_disconnect(pColumn, m_aColumnSignalIds.back()); m_aColumnSignalIds.pop_back(); + + // unset "instance" to avoid dangling "instance" points in any CustomCellRenderers + GList *pRenderers = gtk_cell_layout_get_cells(GTK_CELL_LAYOUT(pColumn)); + for (GList* pRenderer = g_list_first(pRenderers); pRenderer; pRenderer = g_list_next(pRenderer)) + { + GtkCellRenderer* pCellRenderer = GTK_CELL_RENDERER(pRenderer->data); + if (!CUSTOM_IS_CELL_RENDERER_SURFACE(pCellRenderer)) + continue; + g_object_set_property(G_OBJECT(pCellRenderer), "instance", &value); + } + g_list_free(pRenderers); } g_list_free(m_pColumns); } @@ -14496,13 +14512,16 @@ bool custom_cell_renderer_surface_get_preferred_size(GtkCellRenderer *cell, GtkInstanceWidget* pWidget = static_cast<GtkInstanceWidget*>(g_value_get_pointer(&value)); - ensure_device(cellsurface, pWidget); - Size aSize; - if (GtkInstanceTreeView* pTreeView = dynamic_cast<GtkInstanceTreeView*>(pWidget)) - aSize = pTreeView->call_signal_custom_get_size(*cellsurface->device, sId); - else if (GtkInstanceComboBox* pComboBox = dynamic_cast<GtkInstanceComboBox*>(pWidget)) - aSize = pComboBox->call_signal_custom_get_size(*cellsurface->device); + + if (pWidget) + { + ensure_device(cellsurface, pWidget); + if (GtkInstanceTreeView* pTreeView = dynamic_cast<GtkInstanceTreeView*>(pWidget)) + aSize = pTreeView->call_signal_custom_get_size(*cellsurface->device, sId); + else if (GtkInstanceComboBox* pComboBox = dynamic_cast<GtkInstanceComboBox*>(pWidget)) + aSize = pComboBox->call_signal_custom_get_size(*cellsurface->device); + } if (orientation == GTK_ORIENTATION_HORIZONTAL) { @@ -14545,6 +14564,10 @@ void custom_cell_renderer_surface_render(GtkCellRenderer* cell, CustomCellRendererSurface *cellsurface = CUSTOM_CELL_RENDERER_SURFACE(cell); GtkInstanceWidget* pWidget = static_cast<GtkInstanceWidget*>(g_value_get_pointer(&value)); + + if (!pWidget) + return; + ensure_device(cellsurface, pWidget); Size aSize(cell_area->width, cell_area->height); |