From 121b1c9126e94fe8c096a24510cd050ecef7fffb Mon Sep 17 00:00:00 2001 From: Robert Knight Date: Wed, 24 Aug 2011 11:02:26 +0100 Subject: [PATCH 1/4] Fix crash in Update Dialog on Mac if update installation fails due to use of uninitialized string variable. --- src/UpdateDialogCocoa.mm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/UpdateDialogCocoa.mm b/src/UpdateDialogCocoa.mm index 28e2bd2..3a2236d 100644 --- a/src/UpdateDialogCocoa.mm +++ b/src/UpdateDialogCocoa.mm @@ -33,10 +33,11 @@ class UpdateDialogPrivate } - (void) reportUpdateError: (id)arg { - NSMutableString* message; + NSMutableString* message = [[NSMutableString alloc] init]; [message appendString:@"There was a problem installing the update: "]; [message appendString:arg]; [dialog->progressLabel setTitleWithMnemonic: message]; + [message release]; } - (void) reportUpdateProgress: (id)arg { From 22d0bd093926824070d33387d5bb39714ff24259 Mon Sep 17 00:00:00 2001 From: Robert Knight Date: Wed, 24 Aug 2011 11:14:39 +0100 Subject: [PATCH 2/4] Display details of any update failure in a message box instead of in the progress label on Mac. This matches the Windows UI and a message box provides more space for text details than a progress label. --- src/UpdateDialogCocoa.mm | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/src/UpdateDialogCocoa.mm b/src/UpdateDialogCocoa.mm index 3a2236d..69ae964 100644 --- a/src/UpdateDialogCocoa.mm +++ b/src/UpdateDialogCocoa.mm @@ -18,12 +18,18 @@ class UpdateDialogPrivate { public: + UpdateDialogPrivate() + : hadError(false) + { + } + UpdateDialogDelegate* delegate; NSAutoreleasePool* pool; NSWindow* window; NSButton* finishButton; NSTextField* progressLabel; NSProgressIndicator* progressBar; + bool hadError; }; @implementation UpdateDialogDelegate @@ -33,10 +39,18 @@ class UpdateDialogPrivate } - (void) reportUpdateError: (id)arg { + dialog->hadError = true; NSMutableString* message = [[NSMutableString alloc] init]; - [message appendString:@"There was a problem installing the update: "]; + [message appendString:@"There was a problem installing the update:\n"]; [message appendString:arg]; - [dialog->progressLabel setTitleWithMnemonic: message]; + + NSAlert* alert = [NSAlert + alertWithMessageText: @"Update Problem" + defaultButton: nil + alternateButton: nil + otherButton: nil + informativeTextWithFormat: message]; + [alert runModal]; [message release]; } - (void) reportUpdateProgress: (id)arg @@ -46,7 +60,19 @@ class UpdateDialogPrivate } - (void) reportUpdateFinished: (id)arg { - [dialog->progressLabel setTitleWithMnemonic:@"Updates installed. Click 'Finish' to restart the application."]; + NSMutableString* message = [[NSMutableString alloc] init]; + if (!dialog->hadError) + { + [message appendString:@"Updates installed."]; + } + else + { + [message appendString:@"Update failed."]; + } + + [message appendString:@" Click 'Finish' to restart the application."]; + [dialog->progressLabel setTitleWithMnemonic:message]; + [message release]; } @end From 1318576cea083f4045180f0dcb7525636e8bf76c Mon Sep 17 00:00:00 2001 From: Robert Knight Date: Wed, 24 Aug 2011 11:28:32 +0100 Subject: [PATCH 3/4] Fix comparison between pos and std::string::npos std::string::npos is defined as the unsigned type size_t but given a value of -1, resulting in a warning when trying to compare an unsigned int with a size_t. Fix this by declaring pos as a size_t. --- src/UpdaterOptions.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/UpdaterOptions.cpp b/src/UpdaterOptions.cpp index 13b15e5..cc3afc1 100644 --- a/src/UpdaterOptions.cpp +++ b/src/UpdaterOptions.cpp @@ -43,7 +43,7 @@ UpdateInstaller::Mode stringToMode(const std::string& modeStr) void UpdaterOptions::parseOldFormatArg(const std::string& arg, std::string* key, std::string* value) { - unsigned int pos = arg.find('='); + size_t pos = arg.find('='); if (pos != std::string::npos) { *key = arg.substr(0,pos); From b0b3fc4eaaef59d43b3f48ab2b9e4a978b141bad Mon Sep 17 00:00:00 2001 From: Robert Knight Date: Wed, 24 Aug 2011 11:30:06 +0100 Subject: [PATCH 4/4] Fix compile errors reported by -Wall -Werror on Mac Correct argument types and return a value from UpdateDialogCocoa::updateRetryCancel() --- src/ProcessUtils.cpp | 2 +- src/UpdateDialogCocoa.mm | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ProcessUtils.cpp b/src/ProcessUtils.cpp index 0707440..aa27fad 100644 --- a/src/ProcessUtils.cpp +++ b/src/ProcessUtils.cpp @@ -195,7 +195,7 @@ void ProcessUtils::runElevatedMac(const std::string& executable, char** argv; argv = (char**) malloc(sizeof(char*) * args.size() + 1); - int i = 0; + unsigned int i = 0; for (std::list::const_iterator iter = args.begin(); iter != args.end(); iter++) { argv[i] = strdup(iter->c_str()); diff --git a/src/UpdateDialogCocoa.mm b/src/UpdateDialogCocoa.mm index 69ae964..dc1e972 100644 --- a/src/UpdateDialogCocoa.mm +++ b/src/UpdateDialogCocoa.mm @@ -147,6 +147,7 @@ void UpdateDialogCocoa::updateError(const std::string& errorMessage) bool UpdateDialogCocoa::updateRetryCancel(const std::string& message) { // TODO + return false; } void UpdateDialogCocoa::updateProgress(int percentage)