fix screen resize

ncmpcpp was sometimes segfaulting while resizing screen, this commit fixes that.
This commit is contained in:
Andrzej Rybczak
2009-10-28 15:16:54 +01:00
parent fa9b58627a
commit b9a14e37ab

View File

@@ -92,17 +92,12 @@ namespace
std::streambuf *cerr_buffer;
bool design_changed = 0;
bool order_resize = 0;
size_t header_height, footer_start_y, footer_height;
void sighandler(GNUC_UNUSED int signal)
void resize_screen()
{
# if !defined(WIN32)
if (signal == SIGPIPE)
{
ShowMessage("Broken pipe signal caught!");
return;
}
# endif // !WIN32
order_resize = 0;
# if defined(USE_PDCURSES)
resize_term(0, 0);
@@ -114,7 +109,11 @@ namespace
refresh();
// get rid of KEY_RESIZE as it sometimes
// corrupts our new cool ReadKey() function
// because KEY_RESIZE doesn't come from stdin
// and thus select cannot detect it
timeout(10);
getch();
timeout(-1);
}
# endif
@@ -193,6 +192,20 @@ namespace
wFooter->Refresh();
}
# if !defined(WIN32)
void sighandler(int signal)
{
if (signal == SIGPIPE)
{
ShowMessage("Broken pipe signal caught!");
}
else if (signal == SIGWINCH)
{
order_resize = 1;
}
}
# endif // !WIN32
void do_at_exit()
{
// restore old cerr buffer
@@ -323,6 +336,9 @@ int main(int argc, char *argv[])
MessagesAllowed = 1;
if (order_resize)
resize_screen();
// header stuff
if (((Timer.tv_sec == past.tv_sec && Timer.tv_usec >= past.tv_usec+500000) || Timer.tv_sec > past.tv_sec)
&& (myScreen == myPlaylist || myScreen == myBrowser || myScreen == myLyrics)
@@ -511,11 +527,7 @@ int main(int argc, char *argv[])
UnlockProgressbar();
UnlockStatusbar();
design_changed = 1;
# if !defined(WIN32)
sighandler(SIGWINCH);
# else
sighandler(0);
# endif // !WIN23
resize_screen();
}
else if (Keypressed(input, Key.GoToParentDir))
{