Ensure filewatcher is closed if something goes wrong
and avoid creating multiple watchers
This commit is contained in:
parent
4d221c3c81
commit
260e2fb7c8
|
@ -1626,9 +1626,16 @@ extern void EmuParseVshFunction
|
|||
|
||||
|
||||
void InitShaderHotloading() {
|
||||
EmuLog(LOG_LEVEL::DEBUG, "Starting shader file watcher...");
|
||||
HANDLE fsWatcherThread = CreateThread(nullptr, 0, [](void *param) -> DWORD {
|
||||
static HANDLE fsWatcherThread = 0;
|
||||
|
||||
if (fsWatcherThread) {
|
||||
EmuLog(LOG_LEVEL::ERROR2, "Ignoring request to start shader file watcher - it has already been started.");
|
||||
return;
|
||||
}
|
||||
|
||||
EmuLog(LOG_LEVEL::DEBUG, "Starting shader file watcher...");
|
||||
|
||||
auto fsWatcher = [](void* param) -> DWORD {
|
||||
// Determine the filename and directory for the fixed function shader
|
||||
char cxbxExePath[MAX_PATH];
|
||||
GetModuleFileName(GetModuleHandle(nullptr), cxbxExePath, MAX_PATH);
|
||||
|
@ -1658,12 +1665,22 @@ void InitShaderHotloading() {
|
|||
}
|
||||
}
|
||||
|
||||
EmuLog(LOG_LEVEL::DEBUG, "Change detected in shader folder");
|
||||
isShaderFolderDirty = true;
|
||||
}
|
||||
else {
|
||||
EmuLog(LOG_LEVEL::ERROR2, "Shader filewatcher failed to get the next notification");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
EmuLog(LOG_LEVEL::DEBUG, "Shader file watcher exiting...");
|
||||
|
||||
// until there is a way to disable hotloading
|
||||
// this is always an error
|
||||
FindCloseChangeNotification(changeHandle);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}, nullptr, 0, nullptr);
|
||||
};
|
||||
|
||||
fsWatcherThread = CreateThread(nullptr, 0, fsWatcher, nullptr, 0, nullptr);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue