Small fixes

This commit is contained in:
Natsumi
2025-12-25 08:35:58 +13:00
parent 44b0c8bfde
commit 6977cfd9a4
5 changed files with 41 additions and 24 deletions

View File

@@ -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
/// <returns><c>true</c> if the given file path is a shortcut, otherwise <c>false</c></returns>
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);
}

View File

@@ -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 });

View File

@@ -32,7 +32,7 @@
const { t } = useI18n();
const { canOpenInstanceInGame } = useInviteStore();
const { canOpenInstanceInGame } = storeToRefs(useInviteStore());
const { tryOpenInstanceInVrc } = useLaunchStore();
const { isOpeningInstance } = storeToRefs(useLaunchStore());

View File

@@ -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[

View File

@@ -9,7 +9,7 @@
<div style="margin-top: 10px">
<div style="display: flex; align-items: center; justify-content: space-between; font-size: 12px">
<span class="name" style="margin-right: 24px">{{ t('dialog.registry_backup.auto_backup') }}</span>
<el-switch v-model="vrcRegistryAutoBackup" @change="setVrcRegistryAutoBackup"></el-switch>
<el-switch :model-value="vrcRegistryAutoBackup" @change="setVrcRegistryAutoBackup"></el-switch>
</div>
<div
style="
@@ -20,7 +20,7 @@
margin-top: 5px;
">
<span class="name" style="margin-right: 24px">{{ t('dialog.registry_backup.ask_to_restore') }}</span>
<el-switch v-model="vrcRegistryAskRestore" @change="setVrcRegistryAskRestore"></el-switch>
<el-switch :model-value="vrcRegistryAskRestore" @change="setVrcRegistryAskRestore"></el-switch>
</div>
<DataTable v-bind="registryBackupTable" style="margin-top: 10px">
<el-table-column :label="t('dialog.registry_backup.name')" prop="name"></el-table-column>