From a8dcab1f001ad5a97c09d810b64ecc277065f488 Mon Sep 17 00:00:00 2001 From: Robert Knight Date: Tue, 23 Aug 2011 20:15:57 +0100 Subject: [PATCH] Add handling in the UI for failed update installation under Windows. In the event of a failed update, display the details in a message box and allow the user to restart the old application once the update has been reverted. Details of the problem will also be written to the log file. --- src/UpdateDialogWin32.cpp | 26 ++++++++++++++++++++++++-- src/UpdateDialogWin32.h | 1 + 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/UpdateDialogWin32.cpp b/src/UpdateDialogWin32.cpp index fb591bd..6e21190 100644 --- a/src/UpdateDialogWin32.cpp +++ b/src/UpdateDialogWin32.cpp @@ -58,6 +58,7 @@ void registerWindowClass() } UpdateDialogWin32::UpdateDialogWin32() +: m_hadError(false) { registerWindowClass(); } @@ -123,6 +124,9 @@ void UpdateDialogWin32::exec() void UpdateDialogWin32::updateError(const std::string& errorMessage) { + Message* message = new Message(Message::UpdateFailed); + message->message = errorMessage; + SendNotifyMessage(m_window.GetHwnd(),WM_USER,reinterpret_cast(message),0); } bool UpdateDialogWin32::updateRetryCancel(const std::string& message) @@ -169,13 +173,31 @@ LRESULT WINAPI UpdateDialogWin32::windowProc(HWND window, UINT message, WPARAM w switch (message->type) { case Message::UpdateFailed: + { + m_hadError = true; + std::string text = "There was a problem installing the update:\n\n" + + message->message; + MessageBox(m_window.GetHwnd(),text.c_str(),"Update Problem",MB_OK); + } break; case Message::UpdateProgress: m_progressBar.SetPos(message->progress); break; case Message::UpdateFinished: - m_finishButton.EnableWindow(true); - m_progressLabel.SetWindowText("Updates installed. Click 'Finish' to restart the application."); + { + std::string message; + m_finishButton.EnableWindow(true); + if (m_hadError) + { + message = "Update failed."; + } + else + { + message = "Updates installed."; + } + message += " Click 'Finish' to restart the application."; + m_progressLabel.SetWindowText(message.c_str()); + } break; } delete message; diff --git a/src/UpdateDialogWin32.h b/src/UpdateDialogWin32.h index 11d2972..a5103b2 100644 --- a/src/UpdateDialogWin32.h +++ b/src/UpdateDialogWin32.h @@ -52,5 +52,6 @@ class UpdateDialogWin32 : public UpdateObserver CStatic m_progressLabel; CProgressBar m_progressBar; CButton m_finishButton; + bool m_hadError; };