diff --git a/hecl/blender/hecl_blendershell.py b/hecl/blender/hecl_blendershell.py index af5c30014..872bb9c19 100644 --- a/hecl/blender/hecl_blendershell.py +++ b/hecl/blender/hecl_blendershell.py @@ -1,4 +1,4 @@ -import bpy, sys, os, re, struct +import bpy, sys, os, re, struct, traceback ARGS_PATTERN = re.compile(r'''(?:"([^"]+)"|'([^']+)'|(\S+))''') @@ -16,11 +16,12 @@ if sys.platform == "win32": readfd = msvcrt.open_osfhandle(readfd, os.O_RDONLY | os.O_BINARY) writefd = msvcrt.open_osfhandle(writefd, os.O_WRONLY | os.O_BINARY) err_path = "/Temp" + if 'TEMP' in os.environ: + err_path = os.environ['TEMP'] else: err_path = "/tmp" - -if 'TMPDIR' in os.environ: - err_path = os.environ['TMPDIR'] + if 'TMPDIR' in os.environ: + err_path = os.environ['TMPDIR'] err_path += "/hecl_%016X.derp" % os.getpid() @@ -476,7 +477,6 @@ try: hecl.command(cmdargs, writepipestr, writepipebuf) except Exception: - import traceback fout = open(err_path, 'w') traceback.print_exc(file=fout) fout.close() diff --git a/hecl/include/hecl/Blender/BlenderConnection.hpp b/hecl/include/hecl/Blender/BlenderConnection.hpp index ff4840449..f234b0250 100644 --- a/hecl/include/hecl/Blender/BlenderConnection.hpp +++ b/hecl/include/hecl/Blender/BlenderConnection.hpp @@ -50,9 +50,8 @@ public: Frame }; private: - std::atomic_bool m_lock; + std::atomic_bool m_lock = false; #if _WIN32 - HANDLE m_blenderProc = 0; PROCESS_INFORMATION m_pinfo = {}; std::thread m_consoleThread; bool m_consoleThreadRunning = true; diff --git a/hecl/lib/Blender/BlenderConnection.cpp b/hecl/lib/Blender/BlenderConnection.cpp index 3727a4304..4bcc54121 100644 --- a/hecl/lib/Blender/BlenderConnection.cpp +++ b/hecl/lib/Blender/BlenderConnection.cpp @@ -183,7 +183,7 @@ void BlenderConnection::_blenderDied() std::unique_ptr buf(new char[len+1]); memset(buf.get(), 0, len+1); fread(buf.get(), 1, len, errFp); - BlenderLog.report(logvisor::Fatal, "\n%s", buf.get()); + BlenderLog.report(logvisor::Fatal, "\n%.*s", int(len), buf.get()); } } BlenderLog.report(logvisor::Fatal, "Blender Exception"); @@ -401,7 +401,8 @@ BlenderConnection::BlenderConnection(int verbosityLevel) #endif /* Stash error path and unlink existing file */ - m_errPath = hecl::SystemString(TMPDIR) + hecl::SysFormat(_S("/hecl_%016llX.derp"), (unsigned long long)m_blenderProc); + m_errPath = hecl::SystemString(TMPDIR) + hecl::SysFormat(_S("/hecl_%016llX.derp"), + (unsigned long long)m_pinfo.dwProcessId); hecl::Unlink(m_errPath.c_str()); /* Handle first response */