From 6977cfd9a4034875e5be575423e881cc626ed01a Mon Sep 17 00:00:00 2001 From: Natsumi Date: Thu, 25 Dec 2025 08:35:58 +1300 Subject: [PATCH] Small fixes --- Dotnet/AutoAppLaunchManager.cs | 43 +++++++++++-------- src-electron/main.js | 2 +- src/components/InviteYourself.vue | 2 +- .../Charts/composables/useDateNavigation.js | 14 +++++- .../Settings/dialogs/RegistryBackupDialog.vue | 4 +- 5 files changed, 41 insertions(+), 24 deletions(-) diff --git a/Dotnet/AutoAppLaunchManager.cs b/Dotnet/AutoAppLaunchManager.cs index 65bd6b44..dc2d2bc4 100644 --- a/Dotnet/AutoAppLaunchManager.cs +++ b/Dotnet/AutoAppLaunchManager.cs @@ -4,6 +4,7 @@ using System.Diagnostics; using System.IO; using System.Linq; using System.Runtime.InteropServices; +using System.Threading.Tasks; using System.Timers; using NLog; @@ -142,16 +143,16 @@ namespace VRCX { UpdateChildProcesses(); // Ensure the list contains all current child processes. - foreach (var pair in startedProcesses) + Parallel.ForEach(startedProcesses.ToArray(), pair => { var processes = pair.Value; - - foreach (var pid in processes) + var pids = processes.ToArray(); + foreach (var pid in pids) { if (!WinApi.HasProcessExited(pid)) KillProcessTree(pid); } - } + }); startedProcesses.Clear(); } @@ -176,9 +177,7 @@ namespace VRCX { return pids; } - - // Gonna be honest, not gonna spin up a 32bit windows VM to make sure this works. but it should. - // Does VRCX even run on 32bit windows? + PROCESSENTRY32 procEntry = new PROCESSENTRY32(); procEntry.dwSize = (uint)Marshal.SizeOf(typeof(PROCESSENTRY32)); @@ -190,7 +189,7 @@ namespace VRCX { pids.Add((int)procEntry.th32ProcessID); - if(recursive) // Recursively find child processes + if (recursive) // Recursively find child processes pids.AddRange(FindChildProcesses((int)procEntry.th32ProcessID)); } } @@ -209,12 +208,21 @@ namespace VRCX var pids = FindChildProcesses(pid); pids.Add(pid); // Kill parent - foreach (int p in pids) + foreach (var p in pids) { try { - using (Process proc = Process.GetProcessById(p)) - proc.Kill(); + using var proc = Process.GetProcessById(p); + if (proc.HasExited) + continue; + + if (proc.CloseMainWindow()) + continue; + + if (proc.WaitForExit(1000)) + continue; + + proc.Kill(); } catch { @@ -361,14 +369,11 @@ namespace VRCX /// true if the given file path is a shortcut, otherwise false private static bool IsShortcutFile(string filePath) { - byte[] headerBytes = new byte[4]; - using (FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) - { - if (fileStream.Length >= 4) - { - fileStream.Read(headerBytes, 0, 4); - } - } + var headerBytes = new byte[4]; + using var fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); + if (fileStream.Length < 4) + return false; + fileStream.ReadExactly(headerBytes, 0, 4); return headerBytes.SequenceEqual(shortcutSignatureBytes); } diff --git a/src-electron/main.js b/src-electron/main.js index 6428cb8a..d9de2c7c 100644 --- a/src-electron/main.js +++ b/src-electron/main.js @@ -700,7 +700,7 @@ async function createDesktopFile() { // Download the icon and save it to the target directory const iconPath = path.join(homePath, '.local/share/icons/VRCX.png'); - if (!fs.existsSync(iconPath)) { + if (!fs.existsSync(iconPath) || fs.statSync(iconPath).size === 0) { const iconDir = path.dirname(iconPath); if (!fs.existsSync(iconDir)) { fs.mkdirSync(iconDir, { recursive: true }); diff --git a/src/components/InviteYourself.vue b/src/components/InviteYourself.vue index 3c350725..658aa436 100644 --- a/src/components/InviteYourself.vue +++ b/src/components/InviteYourself.vue @@ -32,7 +32,7 @@ const { t } = useI18n(); - const { canOpenInstanceInGame } = useInviteStore(); + const { canOpenInstanceInGame } = storeToRefs(useInviteStore()); const { tryOpenInstanceInVrc } = useLaunchStore(); const { isOpeningInstance } = storeToRefs(useLaunchStore()); diff --git a/src/views/Charts/composables/useDateNavigation.js b/src/views/Charts/composables/useDateNavigation.js index 756b2ea4..cf177628 100644 --- a/src/views/Charts/composables/useDateNavigation.js +++ b/src/views/Charts/composables/useDateNavigation.js @@ -40,9 +40,19 @@ export function useDateNavigation(allDateOfActivity, reloadData) { const idx = allDateOfActivityArray.value.findIndex((date) => date.isSame(selectedDate.value, 'day') ); + + // when invalid date is selected, find the next closest date + if (idx === -1 && !isNext) { + const newIdx = allDateOfActivityArray.value.findIndex((date) => + date.isBefore(selectedDate.value, 'day') + ); + selectedDate.value = allDateOfActivityArray.value[newIdx].toDate(); + reloadData(); + return; + } + if (idx !== -1) { const newIdx = isNext ? idx - 1 : idx + 1; - if (newIdx >= 0 && newIdx < allDateOfActivityArray.value.length) { selectedDate.value = allDateOfActivityArray.value[newIdx].toDate(); @@ -50,6 +60,8 @@ export function useDateNavigation(allDateOfActivity, reloadData) { return; } } + + // Fallback to the first/last date selectedDate.value = isNext ? allDateOfActivityArray.value[0].toDate() : allDateOfActivityArray.value[ diff --git a/src/views/Settings/dialogs/RegistryBackupDialog.vue b/src/views/Settings/dialogs/RegistryBackupDialog.vue index cd5d8a51..4896cacd 100644 --- a/src/views/Settings/dialogs/RegistryBackupDialog.vue +++ b/src/views/Settings/dialogs/RegistryBackupDialog.vue @@ -9,7 +9,7 @@
{{ t('dialog.registry_backup.auto_backup') }} - +
{{ t('dialog.registry_backup.ask_to_restore') }} - +