Skip to content

Commit 029aae4

Browse files
committed
fix nullref if input or output field is empty
1 parent a06bbdc commit 029aae4

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

MainWindow.xaml.cs

+2-5
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ namespace PointCloudConverter
3030
{
3131
public partial class MainWindow : Window
3232
{
33-
static readonly string version = "05.04.2025";
33+
static readonly string version = "08.04.2025";
3434
static readonly string appname = "PointCloud Converter - " + version;
3535
static readonly string rootFolder = AppDomain.CurrentDomain.BaseDirectory;
3636

@@ -1865,11 +1865,8 @@ private void chkManualOffset_Checked(object sender, RoutedEventArgs e)
18651865

18661866
private void btnCopyToClipboard_Click(object sender, RoutedEventArgs e)
18671867
{
1868-
// copy console to clipboard
1869-
System.Windows.Clipboard.SetText(txtConsole.Text);
1870-
// focus
1868+
Clipboard.SetText(txtConsole.Text);
18711869
txtConsole.Focus();
1872-
// select all text
18731870
txtConsole.SelectAll();
18741871
e.Handled = true;
18751872
}

Tools/ArgParser.cs

+20-2
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,12 @@ public static ImportSettings Parse(string[] args, string rootFolder, ILogger log
227227
case "-input":
228228
Log.Write("input = " + param);
229229

230+
if (string.IsNullOrEmpty(param.Trim()))
231+
{
232+
importSettings.errors.Add("Input file not defined: " + param);
233+
break;
234+
}
235+
230236
// remove quotes (needed for paths with spaces)
231237
param = param.Trim('"');
232238

@@ -291,6 +297,14 @@ public static ImportSettings Parse(string[] args, string rootFolder, ILogger log
291297
case "-output":
292298
Log.Write("output = " + param);
293299

300+
if (string.IsNullOrEmpty(param.Trim()))
301+
{
302+
importSettings.errors.Add("Output not defined: " + param);
303+
break;
304+
}
305+
306+
param = param.Trim('"');
307+
294308
// check if relative or not
295309
if (Path.IsPathRooted(param) == false)
296310
{
@@ -663,7 +677,7 @@ public static ImportSettings Parse(string[] args, string rootFolder, ILogger log
663677
}
664678
else
665679
{
666-
importSettings.errors.Add("Invalid offset parameter: " + param);
680+
importSettings.errors.Add("Invalid offset parameter (Use: min or legacy): " + param);
667681
}
668682
}
669683
else // autooffset
@@ -784,7 +798,7 @@ public static ImportSettings Parse(string[] args, string rootFolder, ILogger log
784798

785799
if (param != "legacy" && param != "min")
786800
{
787-
importSettings.errors.Add("Invalid offsetmode parameter: " + param);
801+
importSettings.errors.Add("Invalid offset parameter: (Use: min or legacy)" + param);
788802
}
789803
else
790804
{
@@ -847,6 +861,9 @@ public static ImportSettings Parse(string[] args, string rootFolder, ILogger log
847861
Tools.PrintHelpAndExit(argValueSeparator, waitEnter: true);
848862
}
849863

864+
865+
// *** VALIDATE SETTINGS ***
866+
850867
// check that we had input
851868
if (importSettings.inputFiles.Count == 0 || string.IsNullOrEmpty(importSettings.inputFiles[0]) == true)
852869
{
@@ -916,6 +933,7 @@ public static ImportSettings Parse(string[] args, string rootFolder, ILogger log
916933
}
917934
} // have input
918935

936+
919937
// check required settings
920938
if (importSettings.exportFormat == ExportFormat.Unknown)
921939
{

0 commit comments

Comments
 (0)