mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-12 20:49:06 +08:00
Don't crash when no serial ports are available on Windows
This commit is contained in:
parent
80620a5e94
commit
e50bbc0245
@ -322,9 +322,13 @@ sub scan_serial_ports {
|
||||
# Windows
|
||||
if (eval "use Win32::TieRegistry; 1") {
|
||||
my $ts = Win32::TieRegistry->new("HKEY_LOCAL_MACHINE\\HARDWARE\\DEVICEMAP\\SERIALCOMM",
|
||||
{ Access => Win32::TieRegistry::KEY_READ() });
|
||||
$ts->Tie(\my %reg);
|
||||
push @ports, sort values %reg;
|
||||
{ Access => 'KEY_READ' });
|
||||
if ($ts) {
|
||||
# when no serial ports are available, the registry key doesn't exist and
|
||||
# TieRegistry->new returns undef
|
||||
$ts->Tie(\my %reg);
|
||||
push @ports, sort values %reg;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
# UNIX and OS X
|
||||
|
Loading…
x
Reference in New Issue
Block a user