[Scummvm-git-logs] scummvm master -> f74f8e3c531c9020e6646c0aa4fabf76e69070f5

sev- sev at scummvm.org
Fri Nov 8 09:19:10 CET 2019


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
f74f8e3c53 WIN32: Exit when WinSparkle runs installer


Commit: f74f8e3c531c9020e6646c0aa4fabf76e69070f5
    https://github.com/scummvm/scummvm/commit/f74f8e3c531c9020e6646c0aa4fabf76e69070f5
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2019-11-08T09:19:07+01:00

Commit Message:
WIN32: Exit when WinSparkle runs installer

Trac #10368

Changed paths:
    backends/platform/sdl/win32/win32.cpp
    backends/updates/win32/win32-updates.cpp
    backends/updates/win32/win32-updates.h


diff --git a/backends/platform/sdl/win32/win32.cpp b/backends/platform/sdl/win32/win32.cpp
index 5f35d46..e7dc2af 100644
--- a/backends/platform/sdl/win32/win32.cpp
+++ b/backends/platform/sdl/win32/win32.cpp
@@ -117,7 +117,7 @@ void OSystem_Win32::initBackend() {
 
 #if defined(USE_SPARKLE)
 	// Initialize updates manager
-	_updateManager = new Win32UpdateManager();
+	_updateManager = new Win32UpdateManager((SdlWindow_Win32*)_window);
 #endif
 
 	// Initialize text to speech
diff --git a/backends/updates/win32/win32-updates.cpp b/backends/updates/win32/win32-updates.cpp
index aebeab5..868f5d8 100644
--- a/backends/updates/win32/win32-updates.cpp
+++ b/backends/updates/win32/win32-updates.cpp
@@ -27,10 +27,12 @@
 #include "backends/updates/win32/win32-updates.h"
 
 #ifdef USE_SPARKLE
+#include "backends/platform/sdl/win32/win32-window.h"
 #include "common/translation.h"
 #include "common/config-manager.h"
 
 #include <time.h>
+#include <windows.h>
 #include <winsparkle.h>
 
 /**
@@ -50,10 +52,15 @@
  * https://winsparkle.org/
  *
  */
-Win32UpdateManager::Win32UpdateManager() {
-    const char *appcastUrl = "https://www.scummvm.org/appcasts/macosx/release.xml";
 
-    win_sparkle_set_appcast_url(appcastUrl);
+static SdlWindow_Win32 *_window;
+
+Win32UpdateManager::Win32UpdateManager(SdlWindow_Win32 *window) {
+	_window = window;
+	const char *appcastUrl = "https://www.scummvm.org/appcasts/macosx/release.xml";
+	win_sparkle_set_appcast_url(appcastUrl);
+	win_sparkle_set_can_shutdown_callback(canShutdownCallback);
+	win_sparkle_set_shutdown_request_callback(shutdownRequestCallback);
     win_sparkle_init();
 
     if (!ConfMan.hasKey("updates_check")
@@ -129,4 +136,20 @@ bool Win32UpdateManager::getLastUpdateCheckTimeAndDate(TimeDate &t) {
     return true;
 }
 
+// WinSparkle calls this to ask if we can shut down.
+//  At this point the download has completed, the user has
+//  selected Install Update, and the installer has started.
+//  This callback runs on a non-main thread.
+int Win32UpdateManager::canShutdownCallback() {
+	return true;
+}
+
+// WinSparkle calls this to request that we shut down.
+//  This callback runs on a non-main thread so we post
+//  a WM_CLOSE message to our window so that we exit
+//  cleanly, as opposed to calling g_system->quit().
+void Win32UpdateManager::shutdownRequestCallback() {
+	PostMessage(_window->getHwnd(), WM_CLOSE, 0, 0);
+}
+
 #endif
diff --git a/backends/updates/win32/win32-updates.h b/backends/updates/win32/win32-updates.h
index 71ed9ef..afa2ef9 100644
--- a/backends/updates/win32/win32-updates.h
+++ b/backends/updates/win32/win32-updates.h
@@ -29,9 +29,11 @@
 
 #include "common/updates.h"
 
+class SdlWindow_Win32;
+
 class Win32UpdateManager : public Common::UpdateManager {
 public:
-	Win32UpdateManager();
+	Win32UpdateManager(SdlWindow_Win32 *window);
 	virtual ~Win32UpdateManager();
 
 	virtual void checkForUpdates();
@@ -43,6 +45,10 @@ public:
 	virtual int getUpdateCheckInterval();
 
 	virtual bool getLastUpdateCheckTimeAndDate(TimeDate &t);
+
+private:
+	static int canShutdownCallback();
+	static void shutdownRequestCallback();
 };
 
 #endif





More information about the Scummvm-git-logs mailing list