Skip to content
This repository was archived by the owner on Apr 13, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,14 @@ ifdef ARCH_MAC
# We can't just add the environment's CFLAGS/LDFLAGS because `-march=nocona` makes libpd segfault when initialized.
# Perhaps inline assembly is used in libpd? Who knows.
cd dep/libpd && $(MAKE) MULTI=true STATIC=true ADDITIONAL_CFLAGS='-DPD_LONGINTTYPE="long long" $(DEP_MAC_SDK_FLAGS) -stdlib=libc++' ADDITIONAL_LDFLAGS='$(DEP_MAC_SDK_FLAGS) -stdlib=libc++'
else
ifdef ARCH_WIN
# libpd relies on OS=Windows_NT for platform detection even when cross-compiling.
# Also force heap allocation path to avoid missing alloca.h in some MinGW toolchains.
cd dep/libpd && $(MAKE) OS=Windows_NT MULTI=true STATIC=true ADDITIONAL_CFLAGS='-DPD_LONGINTTYPE="long long" -DDONT_USE_ALLOCA=1'
else
cd dep/libpd && $(MAKE) MULTI=true STATIC=true ADDITIONAL_CFLAGS='-DPD_LONGINTTYPE="long long"'
endif
endif
cd dep/libpd && $(MAKE) install prefix="$(DEP_PATH)"

Expand Down
11 changes: 9 additions & 2 deletions src/PureData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -788,13 +788,20 @@ struct PureData : Module {
(void) std::system(command.c_str());
#elif defined ARCH_WIN
std::string command = editorPath + " \"" + path + "\"";
std::wstring commandW = string::toWstring(command);
int commandWLen = MultiByteToWideChar(CP_UTF8, 0, command.c_str(), -1, NULL, 0);
if (commandWLen <= 0)
return;
std::wstring commandW(commandWLen, L'\0');
MultiByteToWideChar(CP_UTF8, 0, command.c_str(), -1, &commandW[0], commandWLen);
STARTUPINFOW startupInfo;
std::memset(&startupInfo, 0, sizeof(startupInfo));
startupInfo.cb = sizeof(startupInfo);
PROCESS_INFORMATION processInfo;
// Use the non-const [] accessor for commandW. Since C++11, it is null-terminated.
CreateProcessW(NULL, &commandW[0], NULL, NULL, false, 0, NULL, NULL, &startupInfo, &processInfo);
if (CreateProcessW(NULL, &commandW[0], NULL, NULL, false, 0, NULL, NULL, &startupInfo, &processInfo)) {
CloseHandle(processInfo.hThread);
CloseHandle(processInfo.hProcess);
}
#endif
}

Expand Down
Loading