diff --git a/source/vibe/core/file.d b/source/vibe/core/file.d index f3c64fa..8be5b15 100644 --- a/source/vibe/core/file.d +++ b/source/vibe/core/file.d @@ -701,9 +701,11 @@ scope: nothrow { static if (is(typeof(&eventDriver.files.isUnique))) { if (this.isOpen) { - if (m_ctx.driver is (() @trusted => cast(shared)eventDriver)() && eventDriver.files.isUnique(m_fd)) { - try close(); - catch (Exception e) logException(e, "Closing unclosed FileStream during destruction failed"); + if (m_ctx.driver is (() @trusted => cast(shared)eventDriver)()) { + if (eventDriver.files.isUnique(m_fd)) { + try close(); + catch (Exception e) logException(e, "Closing unclosed FileStream during destruction failed"); + } } else logWarn("Destroying FileStream that is still open in a foreign thread (leaked to GC?). This may lead to crashes."); } }