I keep getting `nk_popup_close: Assertion 'popup->parent' failed.` `Aborted (core dumped)` whenever I try using a popup, not sure why
Happens when you hover the cursor in and out of the popup window
Where is your nk_popup_end call?
if (nk_popup_begin(ctx, NK_POPUP_STATIC, "Example", 0, bounds)) {
nk_layout_row_dynamic(ctx, 20, 1);
nk_label(ctx, "Example", NK_TEXT_LEFT);
/* Is it in the braces */
}
/* or outside */
If it's outside the braces then moving it inside the if statement should fix this.
If the nk_popup_end call is inside the braces then something else may be going wrong; a snippet of your popup code may help resolve this.
This snippet fails for example:
if (nk_popup_begin(ctx, NK_POPUP_STATIC, "ERROR", NK_WINDOW_BORDER, nk_rect(0,0,100,100))){
nk_layout_row_dynamic(ctx, 30, 1);
nk_label(ctx,"tom", NK_TEXT_LEFT);
nk_popup_end(ctx);
}
Along with the snippet from overview.c when I plug it into my app
This is what the backtrace gives me
__pthread_kill_implementation (no_tid=0, signo=6, threadid=<optimized out>)
at ./nptl/pthread_kill.c:44
warning: 44 ./nptl/pthread_kill.c: No such file or directory
(gdb) bt
#0 __pthread_kill_implementation (no_tid=0, signo=6, threadid=<optimized out>)
at ./nptl/pthread_kill.c:44
#1 __pthread_kill_internal (signo=6, threadid=<optimized out>)
at ./nptl/pthread_kill.c:78
#2 __GI___pthread_kill (threadid=<optimized out>, signo=signo@entry=6)
at ./nptl/pthread_kill.c:89
#3 0x00007ffff7c4526e in __GI_raise (sig=sig@entry=6)
at ../sysdeps/posix/raise.c:26
#4 0x00007ffff7c288ff in __GI_abort () at ./stdlib/abort.c:79
#5 0x00007ffff7c2881b in __assert_fail_base
(fmt=0x7ffff7dd01e8 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x5555556e1556 "popup->parent", file=file@entry=0x5555556df771 "../lib/nuklear.h", line=line@entry=20911, function=function@entry=0x5555556ea938 <__PRETTY_FUNCTION__.167> "nk_popup_close") at ./assert/assert.c:94
#6 0x00007ffff7c3b507 in __assert_fail
(assertion=0x5555556e1556 "popup->parent", file=0x5555556df771 "../lib/nuklear.h", line=20911, function=0x5555556ea938 <__PRETTY_FUNCTION__.167> "nk_popup_close") at ./assert/assert.c:103
#7 0x00005555555c0c7e in nk_tooltip_end ()
If it helps, I'm using the glfw_opengl3 backend
Are you using nk_popup_* or nk_tooltip_*?
Could you post the code of the window with the popup/tooltip?
I have this code preceding it:
if (nk_widget_is_hovered(ctx)){
nk_tooltip_begin(ctx, 450);
nk_layout_row_dynamic(ctx, 25, 1);
nk_label(ctx, "Your password MUST:", NK_TEXT_LEFT);
nk_labelf(ctx, NK_TEXT_LEFT, "1) Be at least %d characters long", MINIMUM_PASSWORD_LENGTH);
nk_label(ctx, "2) Contain at least 1 lowercase letter", NK_TEXT_LEFT);
nk_label(ctx, "3) Contain at least 1 uppercase letter", NK_TEXT_LEFT);
nk_label(ctx, "4) Contain at least 1 digit", NK_TEXT_LEFT);
nk_label(ctx, "5) Contain at least 1 symbol", NK_TEXT_LEFT);
nk_tooltip_end(ctx);
}
if I comment out this block, no issue ...
This is bizarre
nk_popup_begin is failing without begin caught.
If you change your tooltip code to
if (nk_widget_is_hovered(ctx) && nk_tooltip_begin(ctx, 450)) {
nk_layout_row_dynamic(ctx, 25, 1);
nk_label(ctx, "Your password MUST:", NK_TEXT_LEFT);
nk_labelf(ctx, NK_TEXT_LEFT, "1) Be at least %d characters long", MINIMUM_PASSWORD_LENGTH);
nk_label(ctx, "2) Contain at least 1 lowercase letter", NK_TEXT_LEFT);
nk_label(ctx, "3) Contain at least 1 uppercase letter", NK_TEXT_LEFT);
nk_label(ctx, "4) Contain at least 1 digit", NK_TEXT_LEFT);
nk_label(ctx, "5) Contain at least 1 symbol", NK_TEXT_LEFT);
nk_tooltip_end(ctx);
}
a different assert should trigger and show the root of the issue.
nuklear.h:21065: nk_popup_begin: Assertion `!((int)panel->type & (int)NK_PANEL_SET_POPUP) && "popups are not allowed to have popups"' failed.
Nuklear currently doesn't allow nested popups or multiple active popups at the same time.
Note: nk_tooltip_* calls nk_popup_* so all popup restrictions apply to tooltips as well.
You could try closing the popup before ending it.
if (nk_popup_begin(ctx, NK_POPUP_STATIC, "Example", NK_WINDOW_BORDER, nk_rect(100,100,100,100))) {
...
/* close before ending popup */
nk_popup_close(ctx);
nk_popup_end(ctx);
}
This will allow your to have multiple popups, but some widgets won't work properly in the popup.
Due to how tooltips are implemented there is currently no way to have multiple. https://github.com/Immediate-Mode-UI/Nuklear/issues/660#issuecomment-2229986028
well, my solution: I reverted to using labels instead of the second popup But thank you for clearing up 👏