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 committed Jan 5, 2024
1 parent 489a0fe commit 8f49e99
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 @@ -842,8 +842,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 @@ -854,6 +852,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 8f49e99

Please sign in to comment.