summaryrefslogtreecommitdiff
path: root/vcl/unx/gtk3
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2022-01-27 09:01:08 +0000
committerCaolán McNamara <caolanm@redhat.com>2022-01-27 11:44:25 +0100
commit0c7c475080a8d941db74060428a4a607e1a39b33 (patch)
tree2ad1e58662590b1e6e664b71a40a4953bad3e395 /vcl/unx/gtk3
parent6db8c9c40bbeb8c4c4601d0a05151754727a2dc6 (diff)
cid#1497856 Unchecked dynamic_cast
and cid#1497857 Unchecked dynamic_cast cid#1497858 Unchecked dynamic_cast cid#1497859 Unchecked dynamic_cast cid#1497860 Unchecked dynamic_cast cid#1497861 Unchecked dynamic_cast Change-Id: I29d3abc66e86bcf03ebcd6cc0ea9dfbc24f8ff3d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129025 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl/unx/gtk3')
-rw-r--r--vcl/unx/gtk3/gtkinst.cxx27
1 files changed, 11 insertions, 16 deletions
diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx
index 5d681cf6cd23..e2801448ac73 100644
--- a/vcl/unx/gtk3/gtkinst.cxx
+++ b/vcl/unx/gtk3/gtkinst.cxx
@@ -6199,38 +6199,33 @@ public:
virtual void change_default_widget(weld::Widget* pOld, weld::Widget* pNew) override
{
-#if GTK_CHECK_VERSION(4, 0, 0)
GtkInstanceWidget* pGtkNew = dynamic_cast<GtkInstanceWidget*>(pNew);
GtkWidget* pWidgetNew = pGtkNew ? pGtkNew->getWidget() : nullptr;
+#if GTK_CHECK_VERSION(4, 0, 0)
gtk_window_set_default_widget(m_pWindow, pWidgetNew);
(void)pOld;
#else
- if (!pOld)
- recursively_unset_default_buttons();
- else
- {
- GtkInstanceWidget* pGtkOld = dynamic_cast<GtkInstanceWidget*>(pOld);
- GtkWidget* pWidgetOld = pGtkOld->getWidget();
+ GtkInstanceWidget* pGtkOld = dynamic_cast<GtkInstanceWidget*>(pOld);
+ GtkWidget* pWidgetOld = pGtkOld ? pGtkOld->getWidget() : nullptr;
+ if (pWidgetOld)
g_object_set(G_OBJECT(pWidgetOld), "has-default", false, nullptr);
- }
- if (pNew)
- {
- GtkInstanceWidget* pGtkNew = dynamic_cast<GtkInstanceWidget*>(pNew);
- GtkWidget* pWidgetNew = pGtkNew->getWidget();
+ else
+ recursively_unset_default_buttons();
+ if (pWidgetNew)
g_object_set(G_OBJECT(pWidgetNew), "has-default", true, nullptr);
- }
#endif
}
virtual bool is_default_widget(const weld::Widget* pCandidate) const override
{
const GtkInstanceWidget* pGtkCandidate = dynamic_cast<const GtkInstanceWidget*>(pCandidate);
- GtkWidget* pWidget = pGtkCandidate->getWidget();
+ GtkWidget* pWidget = pGtkCandidate ? pGtkCandidate->getWidget() : nullptr;
#if GTK_CHECK_VERSION(4, 0, 0)
- return gtk_window_get_default_widget(m_pWindow) == pWidget;
+ return pWidget && gtk_window_get_default_widget(m_pWindow) == pWidget;
#else
gboolean has_default(false);
- g_object_get(G_OBJECT(pWidget), "has-default", &has_default, nullptr);
+ if (pWidget)
+ g_object_get(G_OBJECT(pWidget), "has-default", &has_default, nullptr);
return has_default;
#endif
}