Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I keep getting nk_popup_close: Assertion 'popup->parent' failed. Aborted (core dumped) whenever I try using a popup, not sure why #683

Open
quadroli opened this issue Sep 4, 2024 · 9 comments

Comments

@quadroli
Copy link

quadroli commented Sep 4, 2024

Happens when you hover the cursor in and out of the popup window

@quadroli quadroli changed the title I keep getting nk_popup_close: Assertion popup->parent' failed. Aborted (core dumped)` whenever I try using a popup, not sure why I keep getting nk_popup_close: Assertion 'popup->parent' failed. Aborted (core dumped) whenever I try using a popup, not sure why Sep 4, 2024
@quadroli quadroli changed the title I keep getting nk_popup_close: Assertion 'popup->parent' failed. Aborted (core dumped) whenever I try using a popup, not sure why I keep getting nk_popup_close: Assertion 'popup->parent' failed. Aborted (core dumped) whenever I try using a popup, not sure why Sep 4, 2024
@PROP65
Copy link
Contributor

PROP65 commented Sep 5, 2024

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.

@quadroli
Copy link
Author

quadroli commented Sep 5, 2024

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

@quadroli
Copy link
Author

quadroli commented Sep 5, 2024

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 ()

@quadroli
Copy link
Author

quadroli commented Sep 5, 2024

If it helps, I'm using the glfw_opengl3 backend

@PROP65
Copy link
Contributor

PROP65 commented Sep 6, 2024

Are you using nk_popup_* or nk_tooltip_*?
Could you post the code of the window with the popup/tooltip?

@quadroli
Copy link
Author

quadroli commented Sep 6, 2024

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 ...

@quadroli
Copy link
Author

quadroli commented Sep 6, 2024

This is bizarre

@PROP65
Copy link
Contributor

PROP65 commented Sep 7, 2024

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.
#660 (comment)

@quadroli
Copy link
Author

quadroli commented Sep 7, 2024

well, my solution: I reverted to using labels instead of the second popup
But thank you for clearing up 👏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants