vcl/unx/gtk4/convert3to4.cxx | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
New commits: commit f7fd2d4e3ec89afa524b3dac1c8533acafa9a015 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Tue Apr 12 16:01:33 2022 +0100 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Tue Apr 12 20:50:03 2022 +0200 gtk4: cairo_gobject_surface_get_type() needs to be called at least once before "CairoSurface" can be resolved to its type, this worked in gtk3 because there was some fallback code which guessed what function name was needed to call to get it, but that's not present in gtk4 Change-Id: I85a957ecd37e0e7a572578e8273152fbb19dac3c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132920 Tested-by: Caolán McNamara <caol...@redhat.com> Reviewed-by: Caolán McNamara <caol...@redhat.com> diff --git a/vcl/unx/gtk4/convert3to4.cxx b/vcl/unx/gtk4/convert3to4.cxx index 747ea7553093..470b12de490a 100644 --- a/vcl/unx/gtk4/convert3to4.cxx +++ b/vcl/unx/gtk4/convert3to4.cxx @@ -15,6 +15,7 @@ #include <comphelper/processfactory.hxx> #include <unx/gtk/gtkdata.hxx> #include <vcl/builder.hxx> +#include <cairo/cairo-gobject.h> #include "convert3to4.hxx" namespace @@ -1502,6 +1503,17 @@ ConvertResult Convert3To4(const css::uno::Reference<css::xml::dom::XNode>& xNode return ConvertResult(bChildCanFocus, bHasVisible, bHasIconSize, bAlwaysShowImage, bUseUnderline, bVertOrientation, bXAlign, eImagePos, xPropertyLabel, xPropertyIconName); } + +std::once_flag cairo_surface_type_flag; + +void ensure_cairo_surface_type() +{ + // cairo_gobject_surface_get_type needs to be called at least once for + // g_type_from_name to be able to resolve "CairoSurface". In gtk3 there was fallback + // mechanism to attempt to resolve such "missing" types which is not in place for + // gtk4 so ensure it can be found explicitly + std::call_once(cairo_surface_type_flag, []() { cairo_gobject_surface_get_type(); }); +} } void builder_add_from_gtk3_file(GtkBuilder* pBuilder, const OUString& rUri) @@ -1533,6 +1545,8 @@ void builder_add_from_gtk3_file(GtkBuilder* pBuilder, const OUString& rUri) css::uno::Reference<css::xml::sax::XDocumentHandler>(xWriter, css::uno::UNO_QUERY_THROW), css::uno::Sequence<css::beans::StringPair>()); + ensure_cairo_surface_type(); + // feed it to GtkBuilder css::uno::Reference<css::io::XSeekable> xTempSeek(xTempStream, css::uno::UNO_QUERY_THROW); xTempSeek->seek(0);