From c44ad963a6e7d2d80eeee7ef82a3ab53d6448486 Mon Sep 17 00:00:00 2001 From: abraunegg Date: Thu, 5 Oct 2023 17:41:31 +1100 Subject: [PATCH] Update main.d * Fix --version segfault --- src/main.d | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/src/main.d b/src/main.d index f1d574f1c..f50f7a4ab 100644 --- a/src/main.d +++ b/src/main.d @@ -75,17 +75,18 @@ int main(string[] cliArgs) { if (itemDB !is null) { // Make sure the .wal file is incorporated into the main db before we exit itemDB.performVacuum(); + object.destroy(itemDB); } - // Cleanup any existing dry-run elements ... these should never be left hanging around - cleanupDryRunDatabaseFiles(appConfig.databaseFilePathDryRun); - - // Free object and memory - object.destroy(appConfig); - object.destroy(oneDriveApiInstance); - object.destroy(selectiveSync); - object.destroy(syncEngineInstance); - object.destroy(itemDB); + // Free other objects and memory + if (appConfig !is null) { + // Cleanup any existing dry-run elements ... these should never be left hanging around + cleanupDryRunDatabaseFiles(appConfig.databaseFilePathDryRun); + object.destroy(appConfig); + } + if (oneDriveApiInstance !is null) object.destroy(oneDriveApiInstance); + if (selectiveSync !is null) object.destroy(selectiveSync); + if (syncEngineInstance !is null) object.destroy(syncEngineInstance); } scope(failure) { @@ -96,17 +97,18 @@ int main(string[] cliArgs) { if (itemDB !is null) { // Make sure the .wal file is incorporated into the main db before we exit itemDB.performVacuum(); + object.destroy(itemDB); } - // Cleanup any existing dry-run elements ... these should never be left hanging around - cleanupDryRunDatabaseFiles(appConfig.databaseFilePathDryRun); - - // Free object and memory - object.destroy(appConfig); - object.destroy(oneDriveApiInstance); - object.destroy(selectiveSync); - object.destroy(syncEngineInstance); - object.destroy(itemDB); + // Free other objects and memory + if (appConfig !is null) { + // Cleanup any existing dry-run elements ... these should never be left hanging around + cleanupDryRunDatabaseFiles(appConfig.databaseFilePathDryRun); + object.destroy(appConfig); + } + if (oneDriveApiInstance !is null) object.destroy(oneDriveApiInstance); + if (selectiveSync !is null) object.destroy(selectiveSync); + if (syncEngineInstance !is null) object.destroy(syncEngineInstance); } // Read in application options as passed in