vcl/unx/gtk3/gtkinst.cxx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
New commits: commit 47b7e11fd7345fcaaf186706319636c135cdb5e8 Author: Stephan Bergmann <sberg...@redhat.com> AuthorDate: Mon Feb 13 15:58:09 2023 +0100 Commit: Stephan Bergmann <sberg...@redhat.com> CommitDate: Mon Feb 13 15:54:51 2023 +0000 Preserve nullptr between gtk_assistant_get/set_page_title ...in case that might make any difference. Even though <https://docs.gtk.org/gtk3/method.Assistant.get_page_title.html> and <https://docs.gtk.org/gtk3/method.Assistant.set_page_title.html> claim that this must be "a NUL terminated UTF-8 string", it can apparently also be null. This is a follow-up to 6ed7a3cc51e560c6b2a6894f6829c0ac9f991ef2 "tdf#153501 Fix OString construction from nullptr", and at least the recipe in the comment at <https://bugs.documentfoundation.org/show_bug.cgi?id=153501#c0> "Crash when trying to do WollMux mail merge" still works with this change. Change-Id: I9851bbf31cfa5a85ef5d8c7d19a790d004984d0b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146909 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sberg...@redhat.com> diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx index f0923cff2ccd..9e224392b37f 100644 --- a/vcl/unx/gtk3/gtkinst.cxx +++ b/vcl/unx/gtk3/gtkinst.cxx @@ -10,6 +10,7 @@ #include <sal/config.h> #include <deque> +#include <optional> #include <stack> #include <string.h> #include <string_view> @@ -7695,12 +7696,14 @@ public: GtkWidget* pPage = gtk_assistant_get_nth_page(m_pAssistant, nOldIndex); g_object_ref(pPage); - auto const title = gtk_assistant_get_page_title(m_pAssistant, pPage); - OString sTitle(title == nullptr ? "" : title); + std::optional<OString> sTitle; + if (auto const title = gtk_assistant_get_page_title(m_pAssistant, pPage)) { + sTitle = title; + } gtk_assistant_remove_page(m_pAssistant, nOldIndex); gtk_assistant_insert_page(m_pAssistant, pPage, nNewIndex); gtk_assistant_set_page_type(m_pAssistant, pPage, GTK_ASSISTANT_PAGE_CUSTOM); - gtk_assistant_set_page_title(m_pAssistant, pPage, sTitle.getStr()); + gtk_assistant_set_page_title(m_pAssistant, pPage, sTitle ? sTitle->getStr() : nullptr); #if !GTK_CHECK_VERSION(4, 0, 0) gtk_container_forall(GTK_CONTAINER(m_pSidebar), wrap_sidebar_label, nullptr); #endif