Skip to content

Commit 4ddff98

Browse files
committed
fix build report null ref, if no project path found in editor.log
1 parent a9a8212 commit 4ddff98

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

UnityLauncherPro/GetProjects.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@ public static List<Project> Scan(bool getGitBranch = false, bool getPlasticBranc
7777
// scan info for custom folders (if not already on the list)
7878
if (AllProjectPaths != null)
7979
{
80-
// custom full list (may contain duplicates)
81-
//foreach (var p in projectsFound)
80+
// iterate custom full project history
8281
foreach (var projectPath in AllProjectPaths)
8382
{
8483
// check if registry list contains this path
@@ -92,7 +91,7 @@ public static List<Project> Scan(bool getGitBranch = false, bool getPlasticBranc
9291
}
9392
}
9493

95-
// if not found from full history list, add
94+
// if not found from full history list, add to projects list
9695
if (found == false)
9796
{
9897
var p = GetProjectInfo(projectPath, getGitBranch, getPlasticBranch, getArguments, showMissingFolders, showTargetPlatform);

UnityLauncherPro/MainWindow.xaml.cs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1981,9 +1981,18 @@ void RefreshBuildReports()
19811981
singleReport.ElapsedTimeMS = long.Parse(ms);
19821982
collectedBuildTime = true;
19831983

1984-
// get streamingassets folder size and add to report, NOTE need to recalculate sizes then?
1985-
long streamingAssetFolderSize = Tools.GetFolderSizeInBytes(Path.Combine(currentBuildReportProjectPath, "Assets", "StreamingAssets"));
1986-
singleReport.Stats.Insert(singleReport.Stats.Count - 1, new BuildReportItem() { Category = "StreamingAssets", Size = Tools.GetBytesReadable(streamingAssetFolderSize) });
1984+
if (string.IsNullOrEmpty(currentBuildReportProjectPath) == false)
1985+
{
1986+
// get streamingassets folder size and add to report, NOTE need to recalculate sizes then?
1987+
string streamingAssetPath = Path.Combine(currentBuildReportProjectPath, "Assets", "StreamingAssets");
1988+
var streamingAssetFolderSize = Tools.GetFolderSizeInBytes(streamingAssetPath);
1989+
singleReport.Stats.Insert(singleReport.Stats.Count - 1, new BuildReportItem() { Category = "StreamingAssets", Size = Tools.GetBytesReadable(streamingAssetFolderSize) });
1990+
}
1991+
else
1992+
{
1993+
// this can happen if editor log file was overwritten with another running editor? (so that start of the log file doesnt contain project path)
1994+
Console.WriteLine("Failed to get project path from build report..");
1995+
}
19871996

19881997
// add all rows and stat rows for this build report
19891998
buildReports.Add(singleReport);
@@ -2062,7 +2071,7 @@ void RefreshBuildReports()
20622071
}
20632072
}
20642073
}
2065-
catch (Exception)
2074+
catch (Exception e)
20662075
{
20672076
gridBuildReport.ItemsSource = null;
20682077
gridBuildReport.Items.Clear();
@@ -2073,7 +2082,8 @@ void RefreshBuildReports()
20732082
txtBuildTime.Text = "";
20742083

20752084
Console.WriteLine("Failed to open editor log or other error in parsing: " + logFile);
2076-
SetStatus("Failed to open editor log or other error in parsing: " + logFile);
2085+
Console.WriteLine(e);
2086+
SetStatus("Failed to open editor log or other parsing error..");
20772087
return;
20782088
}
20792089

UnityLauncherPro/Tools.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1704,6 +1704,7 @@ public static bool CreateDesktopShortCut(Project proj, string batchFolder)
17041704

17051705
internal static long GetFolderSizeInBytes(string currentBuildReportProjectPath)
17061706
{
1707+
// FIXME: 0 is not really correct for missing folder..
17071708
if (Directory.Exists(currentBuildReportProjectPath) == false) return 0;
17081709

17091710
return DirSize(new DirectoryInfo(currentBuildReportProjectPath));

0 commit comments

Comments
 (0)