diff options
author | Caolán McNamara <caolanm@redhat.com> | 2022-01-27 09:01:08 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2022-01-27 11:44:25 +0100 |
commit | 0c7c475080a8d941db74060428a4a607e1a39b33 (patch) | |
tree | 2ad1e58662590b1e6e664b71a40a4953bad3e395 /vcl | |
parent | 6db8c9c40bbeb8c4c4601d0a05151754727a2dc6 (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')
-rw-r--r-- | vcl/source/app/salvtables.cxx | 23 | ||||
-rw-r--r-- | vcl/unx/gtk3/gtkinst.cxx | 27 |
2 files changed, 22 insertions, 28 deletions
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index 00039eb34c34..61789796f473 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -1507,24 +1507,23 @@ void SalInstanceWindow::recursively_unset_default_buttons() { implResetDefault(m void SalInstanceWindow::change_default_widget(weld::Widget* pOld, weld::Widget* pNew) { - if (!pOld) - recursively_unset_default_buttons(); + SalInstanceWidget* pVclNew = dynamic_cast<SalInstanceWidget*>(pNew); + vcl::Window* pWidgetNew = pVclNew ? pVclNew->getWidget() : nullptr; + SalInstanceWidget* pVclOld = dynamic_cast<SalInstanceWidget*>(pOld); + vcl::Window* pWidgetOld = pVclOld ? pVclOld->getWidget() : nullptr; + if (pWidgetOld) + pWidgetOld->set_property("has-default", OUString::boolean(false)); else - { - SalInstanceWidget* pVclOld = dynamic_cast<SalInstanceWidget*>(pOld); - pVclOld->getWidget()->set_property("has-default", OUString::boolean(false)); - } - if (pNew) - { - SalInstanceWidget* pVclNew = dynamic_cast<SalInstanceWidget*>(pNew); - pVclNew->getWidget()->set_property("has-default", OUString::boolean(true)); - } + recursively_unset_default_buttons(); + if (pWidgetNew) + pWidgetNew->set_property("has-default", OUString::boolean(true)); } bool SalInstanceWindow::is_default_widget(const weld::Widget* pCandidate) const { const SalInstanceWidget* pVclCandidate = dynamic_cast<const SalInstanceWidget*>(pCandidate); - return pVclCandidate->getWidget()->GetStyle() & WB_DEFBUTTON; + vcl::Window* pWidget = pVclCandidate ? pVclCandidate->getWidget() : nullptr; + return pWidget && pWidget->GetStyle() & WB_DEFBUTTON; } void SalInstanceWindow::set_window_state(const OString& rStr) 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 } |