diff options
author | Ingo Klöcker <[email protected]> | 2021-05-05 16:52:18 +0000 |
---|---|---|
committer | Ingo Klöcker <[email protected]> | 2021-05-06 08:14:44 +0000 |
commit | 58a217b108e4c4c92306542bf9f2995254809ffb (patch) | |
tree | df08f76a15d734ae801cc657b8939650a596906c /lang/cpp/src/editinteractor.cpp | |
parent | qt: Extend SignKeyJob to create trust signatures (diff) | |
download | gpgme-58a217b108e4c4c92306542bf9f2995254809ffb.tar.gz gpgme-58a217b108e4c4c92306542bf9f2995254809ffb.zip |
cpp: Do not close stdout/stderr when destroying EditInteractor
* lang/cpp/src/editinteractor.cpp (EditInteractor::Private): Initialize
members 'state' and 'debug' in-class. Add member 'debugNeedsClosing'.
(EditInteractor::Private::Private): Remove members initializers.
Remember if 'debug' needs to be closed.
(EditInteractor::Private::~Private): Only close 'debug' if it needs to
be closed.
--
This fixes the problem that after destroying an edit interactor all
debug output went to /dev/null instead of stderr (or stdout) if one
enabled debugging of the edit interactors with GPGMEPP_INTERACTOR_DEBUG
set to stderr (or stdout).
Diffstat (limited to 'lang/cpp/src/editinteractor.cpp')
-rw-r--r-- | lang/cpp/src/editinteractor.cpp | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/lang/cpp/src/editinteractor.cpp b/lang/cpp/src/editinteractor.cpp index 774903d4..e411adac 100644 --- a/lang/cpp/src/editinteractor.cpp +++ b/lang/cpp/src/editinteractor.cpp @@ -62,9 +62,10 @@ public: ~Private(); private: - unsigned int state; + unsigned int state = StartState; Error error; - std::FILE *debug; + std::FILE *debug = nullptr; + bool debugNeedsClosing = false; }; class GpgME::CallbackHelper @@ -174,10 +175,7 @@ static gpgme_error_t edit_interactor_callback(void *opaque, gpgme_status_code_t const gpgme_edit_cb_t GpgME::edit_interactor_callback = ::edit_interactor_callback; EditInteractor::Private::Private(EditInteractor *qq) - : q(qq), - state(StartState), - error(), - debug(nullptr) + : q(qq) { const char *debug_env = std::getenv("GPGMEPP_INTERACTOR_DEBUG"); if (!debug_env) { @@ -189,12 +187,13 @@ EditInteractor::Private::Private(EditInteractor *qq) debug = stderr; } else if (debug_env) { debug = std::fopen(debug_env, "a+"); + debugNeedsClosing = true; } } EditInteractor::Private::~Private() { - if (debug) { + if (debug && debugNeedsClosing) { std::fclose(debug); } } |