From e294c359657e993709dabfe3d8c09b1c5acd816e Mon Sep 17 00:00:00 2001 From: Robert Knight Date: Tue, 23 Aug 2011 16:34:34 +0100 Subject: [PATCH 1/4] Rename UpdaterOptions::script to UpdaterOptions::scriptPath for clarity --- src/UpdaterOptions.cpp | 4 ++-- src/UpdaterOptions.h | 2 +- src/main.cpp | 6 +++--- src/tests/TestUpdaterOptions.cpp | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/UpdaterOptions.cpp b/src/UpdaterOptions.cpp index 996e3a4..869fd06 100644 --- a/src/UpdaterOptions.cpp +++ b/src/UpdaterOptions.cpp @@ -70,7 +70,7 @@ void UpdaterOptions::parseOldFormatArgs(int argc, char** argv) } else if (key == "UpdateScriptFileName") { - script = value; + scriptPath = value; } else if (key == "AppFileName") { @@ -116,7 +116,7 @@ void UpdaterOptions::parse(int argc, char** argv) } if (parser.getValue("script")) { - script = parser.getValue("script"); + scriptPath = parser.getValue("script"); } if (parser.getValue("wait")) { diff --git a/src/UpdaterOptions.h b/src/UpdaterOptions.h index 082ab14..738261c 100644 --- a/src/UpdaterOptions.h +++ b/src/UpdaterOptions.h @@ -12,7 +12,7 @@ class UpdaterOptions UpdateInstaller::Mode mode; std::string installDir; std::string packageDir; - std::string script; + std::string scriptPath; long long waitPid; std::string logFile; diff --git a/src/main.cpp b/src/main.cpp index a777444..aed2f93 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -49,15 +49,15 @@ int main(int argc, char** argv) UpdateInstaller installer; UpdateScript script; - if (!options.script.empty()) + if (!options.scriptPath.empty()) { - script.parse(options.script); + script.parse(options.scriptPath); } LOG(Info,"started updater. install-dir: " + options.installDir + ", package-dir: " + options.packageDir + ", wait-pid: " + intToStr(options.waitPid) - + ", script-path: " + options.script + + ", script-path: " + options.scriptPath + ", mode: " + intToStr(options.mode)); installer.setMode(options.mode); diff --git a/src/tests/TestUpdaterOptions.cpp b/src/tests/TestUpdaterOptions.cpp index 012a551..1d5af1a 100644 --- a/src/tests/TestUpdaterOptions.cpp +++ b/src/tests/TestUpdaterOptions.cpp @@ -20,7 +20,7 @@ void TestUpdaterOptions::testOldFormatArgs() TEST_COMPARE(options.mode,UpdateInstaller::Setup); TEST_COMPARE(options.installDir,"/path/to/app"); TEST_COMPARE(options.packageDir,"/tmp/updater"); - TEST_COMPARE(options.script,"/tmp/updater/file_list.xml"); + TEST_COMPARE(options.scriptPath,"/tmp/updater/file_list.xml"); TEST_COMPARE(options.waitPid,123456); } From fe3fd4e05bd87f72a34483002a83e980c5d86cf3 Mon Sep 17 00:00:00 2001 From: Robert Knight Date: Tue, 23 Aug 2011 16:46:09 +0100 Subject: [PATCH 2/4] Compile the updater as a universal 32/64bit binary on Mac --- CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index d53b4aa..e76d353 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,10 @@ if (WIN32) include_directories(external/zlib/) endif() +if (APPLE) + set(CMAKE_OSX_ARCHITECTURES i386;x86_64) +endif() + add_subdirectory(src) add_subdirectory(external/AnyOption) add_subdirectory(external/minizip) From 91f402afa297eafff40b12f8ed2ed2a0e561347b Mon Sep 17 00:00:00 2001 From: Robert Knight Date: Wed, 24 Aug 2011 10:52:07 +0100 Subject: [PATCH 3/4] Fix warnings about conversion from string literal to char* UpdaterOptions::parse() will probably not have a need to modify its arguments but for consistency with the declaration of main() it takes a char*, so strdup() the strings. --- src/tests/TestUpdaterOptions.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/tests/TestUpdaterOptions.cpp b/src/tests/TestUpdaterOptions.cpp index 1d5af1a..6d6f7c8 100644 --- a/src/tests/TestUpdaterOptions.cpp +++ b/src/tests/TestUpdaterOptions.cpp @@ -7,12 +7,12 @@ void TestUpdaterOptions::testOldFormatArgs() { const int argc = 6; char* argv[argc]; - argv[0] = "updater"; - argv[1] = "CurrentDir=/path/to/app"; - argv[2] = "TempDir=/tmp/updater"; - argv[3] = "UpdateScriptFileName=/tmp/updater/file_list.xml"; - argv[4] = "AppFileName=/path/to/app/theapp"; - argv[5] = "PID=123456"; + argv[0] = strdup("updater"); + argv[1] = strdup("CurrentDir=/path/to/app"); + argv[2] = strdup("TempDir=/tmp/updater"); + argv[3] = strdup("UpdateScriptFileName=/tmp/updater/file_list.xml"); + argv[4] = strdup("AppFileName=/path/to/app/theapp"); + argv[5] = strdup("PID=123456"); UpdaterOptions options; options.parse(argc,argv); @@ -22,6 +22,11 @@ void TestUpdaterOptions::testOldFormatArgs() TEST_COMPARE(options.packageDir,"/tmp/updater"); TEST_COMPARE(options.scriptPath,"/tmp/updater/file_list.xml"); TEST_COMPARE(options.waitPid,123456); + + for (int i=0; i < argc; i++) + { + free(argv[i]); + } } int main(int,char**) From a42e9475b5f0905dbf82dcc8acb891d3ebb603f8 Mon Sep 17 00:00:00 2001 From: Robert Knight Date: Wed, 24 Aug 2011 10:56:08 +0100 Subject: [PATCH 4/4] Disable the window close button in the update dialog on Mac. This prevents the dialog being closed part-way through update installation, leaving the user unable to restart the application afterwards by clicking the 'Finish' button. --- src/UpdateDialogCocoa.mm | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/UpdateDialogCocoa.mm b/src/UpdateDialogCocoa.mm index 1a54e24..28e2bd2 100644 --- a/src/UpdateDialogCocoa.mm +++ b/src/UpdateDialogCocoa.mm @@ -70,8 +70,7 @@ void UpdateDialogCocoa::init() int height = 100; d->window = [[NSWindow alloc] initWithContentRect:NSMakeRect(200, 200, width, height) - styleMask:NSTitledWindowMask | NSClosableWindowMask | - NSMiniaturizableWindowMask + styleMask:NSTitledWindowMask | NSMiniaturizableWindowMask backing:NSBackingStoreBuffered defer:NO]; [d->window setTitle:@"Mendeley Updater"];