From a2b4bf09fdd2bbb914ef92158e7befdd63254dad Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sat, 12 Sep 2015 10:54:55 +0100 Subject: [PATCH] Fix color restoring --- src/ncurses_ui.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/ncurses_ui.cc b/src/ncurses_ui.cc index 8f6e195f..a29bf702 100644 --- a/src/ncurses_ui.cc +++ b/src/ncurses_ui.cc @@ -140,9 +140,6 @@ constexpr struct { unsigned char r, g, b; } builtin_colors[] = { static void restore_colors() { - if (not can_change_color()) - return; - for (size_t i = 8; i < COLORS; ++i) { auto& c = builtin_colors[i]; @@ -287,8 +284,10 @@ NCursesUI::~NCursesUI() { puts("\033[?1004l"); puts("\033[?1002l"); + const bool changed_color = can_change_color(); endwin(); - restore_colors(); + if (changed_color) + restore_colors(); signal(SIGWINCH, SIG_DFL); signal(SIGINT, SIG_DFL); }