Skip to content

Commit

Permalink
Added SP->in_endwin Boolean. While in endwin(), we should use only si…
Browse files Browse the repository at this point in the history
…gnal-safe functions, meaning (at the very least) debugging should be turned off. I think this fixes wmcbrine/PDCurses#134.
  • Loading branch information
Bill-Gray committed Jul 6, 2022
1 parent b196e1d commit 18ff2cb
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions curses.h
Original file line number Diff line number Diff line change
Expand Up @@ -418,8 +418,8 @@ typedef struct
on last key press */
bool return_key_modifiers; /* TRUE if modifier keys are
returned as "real" keys */
bool unused_key_code; /* (was) TRUE if last key is a special key;
used internally by get_wch() */
bool in_endwin; /* if we're in endwin(), we should use
only signal-safe code */
MOUSE_STATUS mouse_status; /* last returned mouse status */
short line_color; /* color of line attributes - default -1 */
attr_t termattrs; /* attribute capabilities */
Expand Down
2 changes: 1 addition & 1 deletion pdcurses/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void PDC_debug(const char *fmt, ...)
time_t now;

assert( SP);
if (!SP || !SP->dbfp)
if (!SP || !SP->dbfp || SP->in_endwin)
return;

time(&now);
Expand Down
2 changes: 2 additions & 0 deletions pdcurses/initscr.c
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ WINDOW *Xinitscr(int argc, char **argv)

int endwin(void)
{
SP->in_endwin = TRUE;
PDC_LOG(("endwin() - called\n"));

/* Allow temporary exit from curses using endwin() */
Expand All @@ -320,6 +321,7 @@ int endwin(void)
assert( SP);
SP->alive = FALSE;

SP->in_endwin = FALSE;
return OK;
}

Expand Down

0 comments on commit 18ff2cb

Please sign in to comment.