Skip to content

Commit

Permalink
create xkb context only after wayland connection is established
Browse files Browse the repository at this point in the history
This prevents memory leaks since the xkb context is not free'ed if the
exception is thrown.
  • Loading branch information
christian-rauch authored and christianrauch committed Feb 2, 2024
1 parent e6be3ae commit 21bded5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions components/pango_windowing/src/display_wayland.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -853,8 +853,6 @@ static const struct wl_registry_listener wregistry_listener = {
};

WaylandDisplay::WaylandDisplay() {
xkb_context = xkb_context_new(XKB_CONTEXT_NO_FLAGS);

wdisplay = wl_display_connect(nullptr);
if (wdisplay == nullptr) {
throw std::runtime_error("Cannot connect to Wayland compositor!");
Expand All @@ -865,6 +863,8 @@ WaylandDisplay::WaylandDisplay() {

wl_display_roundtrip(wdisplay);

xkb_context = xkb_context_new(XKB_CONTEXT_NO_FLAGS);

egl_display = eglGetDisplay((EGLNativeDisplayType)wdisplay);
if(!egl_display) {
std::cerr << "Failed to open EGL display" << std::endl;
Expand Down

0 comments on commit 21bded5

Please sign in to comment.