From 8873b5f36537ccbeae1dd22256f002b0496f5a5c Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 11 Sep 2024 11:33:46 +0200 Subject: [PATCH] LyricsPage: use def_prog_mode()/reset_prog_mode() for spawning the editor Calling ncu_deinit() (and delscreen()) causes ncmpc to crash after returning from the editor. This way, we don't actually deinitialize ncurses and instead just change its state. Closes https://github.com/MusicPlayerDaemon/ncmpc/issues/133 --- NEWS | 1 + src/LyricsPage.cxx | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index d94aa727..219c609b 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,7 @@ ncmpc 0.50 - not yet released * draw progress bar as Unicode double line * add color style "text" for input text controls * remove option "text-editor-ask" +* fix lyrics editor crash * lyrics/musixmatch: add new lyrics extension * lyrics/google: fix partial loading of lyrics * support MPD 0.22 tag "label" (requires libmpdclient 2.17) diff --git a/src/LyricsPage.cxx b/src/LyricsPage.cxx index 6eb14d4c..5613d4aa 100644 --- a/src/LyricsPage.cxx +++ b/src/LyricsPage.cxx @@ -11,7 +11,6 @@ #include "Options.hxx" #include "screen.hxx" #include "plugin.hxx" -#include "ncu.hxx" #include "page/TextPage.hxx" #include "lib/fmt/ToSpan.hxx" #include "client/mpdclient.hxx" @@ -346,15 +345,16 @@ LyricsPage::Edit() noexcept if (!Save()) return; - ncu_deinit(); + def_prog_mode(); + endwin(); /* TODO: fork/exec/wait won't work on Windows, but building a command string for system() is too tricky */ int status; pid_t pid = fork(); if (pid == -1) { + reset_prog_mode(); FmtAlert("{} ({})"sv, _("Can't start editor"), strerror(errno)); - ncu_init(); return; } else if (pid == 0) { execlp(editor, editor, path.c_str(), nullptr); @@ -367,7 +367,7 @@ LyricsPage::Edit() noexcept } while (ret == -1 && errno == EINTR); } - ncu_init(); + reset_prog_mode(); /* TODO: hardly portable */ if (WIFEXITED(status)) {