Clean up stale editor-hInstance comments, add isOwnModulePath edge tests
Drops a false claim about ReaSampler's own editor's hInstance, corrects the real reason for registering the wndproc class against our own module, and covers isOwnModulePath's separator edge cases.
This commit is contained in:
@@ -378,8 +378,8 @@ ui::WindowFacts windowFacts(HWND hwnd) {
|
|||||||
|
|
||||||
bool pointerOverPluginEditor(int screenX, int screenY) {
|
bool pointerOverPluginEditor(int screenX, int screenY) {
|
||||||
// The CLASS procedure's module rather than the window's hInstance: a bare-SDK plugin may
|
// The CLASS procedure's module rather than the window's hInstance: a bare-SDK plugin may
|
||||||
// create its editor with the hInstance of the parent REAPER hands it (ReaSampler 9000's own
|
// create its editor with the hInstance of the parent REAPER hands it, so hInstance would
|
||||||
// editor does), so hInstance would read that plugin as REAPER.
|
// read that plugin as REAPER.
|
||||||
const POINT pt{screenX, screenY};
|
const POINT pt{screenX, screenY};
|
||||||
const HWND hit = WindowFromPoint(pt);
|
const HWND hit = WindowFromPoint(pt);
|
||||||
if (!hit) return false;
|
if (!hit) return false;
|
||||||
|
|||||||
@@ -36,10 +36,10 @@ const std::wstring& childClassName() {
|
|||||||
|
|
||||||
// The module holding a given code address — used to resolve THIS wndProc's own module rather
|
// The module holding a given code address — used to resolve THIS wndProc's own module rather
|
||||||
// than the parent's hInstance REAPER hands us. Registering against the parent would put the class
|
// than the parent's hInstance REAPER hands us. Registering against the parent would put the class
|
||||||
// in REAPER's own module, where a second .vst3 (the other channel) sharing that hInstance could
|
// in REAPER's own module while the wndproc still points into our DLL — a dangling procedure
|
||||||
// collide on the (now channel-forked) name, and any lookup-by-class would resolve into the wrong
|
// pointer once our DLL unloads but REAPER's class registration outlives it. Takes the address
|
||||||
// binary. Takes the address rather than naming wndProc directly so a free function in this
|
// rather than naming wndProc directly so a free function in this anonymous namespace doesn't need
|
||||||
// anonymous namespace doesn't need access to the private member.
|
// access to the private member.
|
||||||
HMODULE moduleHandleFor(void* codeAddress) {
|
HMODULE moduleHandleFor(void* codeAddress) {
|
||||||
HMODULE mod = nullptr;
|
HMODULE mod = nullptr;
|
||||||
GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
|
GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
|
||||||
|
|||||||
@@ -194,6 +194,18 @@ static void testOwnModulePathStableAndBetaDoNotMatchEachOther() {
|
|||||||
CHECK(!isOwnModulePath("C:\\VST3\\reasampler_9000.vst3", "reasampler_9000_beta.vst3"));
|
CHECK(!isOwnModulePath("C:\\VST3\\reasampler_9000.vst3", "reasampler_9000_beta.vst3"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void testOwnModulePathBareFilenameWithNoSeparatorMatches() {
|
||||||
|
CHECK(isOwnModulePath("reasampler_9000.vst3", "reasampler_9000.vst3"));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void testOwnModulePathEmptyPathDoesNotMatch() {
|
||||||
|
CHECK(!isOwnModulePath("", "reasampler_9000.vst3"));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void testOwnModulePathTrailingSeparatorDoesNotMatch() {
|
||||||
|
CHECK(!isOwnModulePath("C:\\VST3\\reasampler_9000.vst3\\", "reasampler_9000.vst3"));
|
||||||
|
}
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
testHostExecutableIsHost();
|
testHostExecutableIsHost();
|
||||||
testOsModulesAreSystem();
|
testOsModulesAreSystem();
|
||||||
@@ -216,6 +228,9 @@ int main() {
|
|||||||
testOwnModulePathCaseFolds();
|
testOwnModulePathCaseFolds();
|
||||||
testOwnModulePathBundlePathForwardAndBackSlash();
|
testOwnModulePathBundlePathForwardAndBackSlash();
|
||||||
testOwnModulePathStableAndBetaDoNotMatchEachOther();
|
testOwnModulePathStableAndBetaDoNotMatchEachOther();
|
||||||
|
testOwnModulePathBareFilenameWithNoSeparatorMatches();
|
||||||
|
testOwnModulePathEmptyPathDoesNotMatch();
|
||||||
|
testOwnModulePathTrailingSeparatorDoesNotMatch();
|
||||||
|
|
||||||
if (g_fail == 0) std::printf("All tests passed.\n");
|
if (g_fail == 0) std::printf("All tests passed.\n");
|
||||||
return g_fail ? 1 : 0;
|
return g_fail ? 1 : 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user