Skip to content

Commit

Permalink
wl: Ensure destroying the previous popup
Browse files Browse the repository at this point in the history
... and reset the reference in the Platform if the destroyed popup
is the same.
  • Loading branch information
psaavedra authored and bykov34 committed Mar 14, 2024
1 parent c781c9c commit e7a1ad5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 4 additions & 1 deletion platform/wayland/cog-platform-wl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1405,7 +1405,10 @@ void
cog_wl_platform_popup_create(CogWlViewport *viewport, WebKitOptionMenu *option_menu)
{
CogWlPlatform *platform = (CogWlPlatform *) cog_platform_get();
g_assert(!platform->popup);

// Destroy the still alive previous popup
if (platform->popup)
cog_wl_platform_popup_destroy();

CogWlPopup *popup = cog_wl_popup_create(viewport, option_menu);
platform->popup = popup;
Expand Down
5 changes: 5 additions & 0 deletions platform/wayland/cog-utils-wl.c
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,11 @@ cog_wl_popup_destroy(CogWlPopup *popup)
g_debug("%s: Destroying @ %p", G_STRFUNC, popup);
g_assert(popup);

// Reset the reference in the Platform if the destroyed popup is the same
CogWlPlatform *platform = (CogWlPlatform *) cog_platform_get();
if (platform->popup == popup)
platform->popup = NULL;

if (popup->option_menu != NULL)
webkit_option_menu_close(popup->option_menu);

Expand Down

0 comments on commit e7a1ad5

Please sign in to comment.