dammit, merge
authorunc0rr
Sun, 03 Apr 2011 19:27:48 +0400
changeset 5097 53e9d9451328
parent 5094 9c3553254100 (current diff)
parent 5096 7d588baaff82 (diff)
child 5098 cb9cf41a208c
dammit, merge
--- a/QTfrontend/CocoaInitializer.h	Sun Apr 03 19:26:53 2011 +0400
+++ b/QTfrontend/CocoaInitializer.h	Sun Apr 03 19:27:48 2011 +0400
@@ -1,7 +1,23 @@
 /*
- * Copyright (C) 2008 Remko Troncon
+ * Hedgewars, a free turn based strategy game
+ * Copyright (c) 2005-2011 Andrey Korotaev <unC0Rr@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  */
 
+// see original example here http://el-tramo.be/blog/mixing-cocoa-and-qt
+
 #ifndef COCOAINITIALIZER_H
 #define COCOAINITIALIZER_H
 
@@ -13,8 +29,7 @@
 
     private:
         class Private;
-        Private* d;
-                Private* c;
+        Private* c;
 };
 
 #endif
--- a/QTfrontend/CocoaInitializer.mm	Sun Apr 03 19:26:53 2011 +0400
+++ b/QTfrontend/CocoaInitializer.mm	Sun Apr 03 19:27:48 2011 +0400
@@ -1,7 +1,23 @@
 /*
- * Copyright (C) 2008 Remko Troncon
+ * Hedgewars, a free turn based strategy game
+ * Copyright (c) 2005-2011 Andrey Korotaev <unC0Rr@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  */
 
+// see original example here http://el-tramo.be/blog/mixing-cocoa-and-qt
+
 #include "CocoaInitializer.h"
 
 #include <AppKit/AppKit.h>
@@ -10,23 +26,19 @@
 
 class CocoaInitializer::Private
 {
-	public:
-		NSAutoreleasePool* autoReleasePool_;
+    public:
+        NSAutoreleasePool* pool;
 };
 
 CocoaInitializer::CocoaInitializer()
 {
-	d = new CocoaInitializer::Private();
-        c = new CocoaInitializer::Private();
-	NSApplicationLoad();
-        c->autoReleasePool_ = [[NSAutoreleasePool alloc] init];
-	d->autoReleasePool_ = [[NSAutoreleasePool alloc] init];
+    c = new CocoaInitializer::Private();
+    NSApplicationLoad();
+    c->pool = [[NSAutoreleasePool alloc] init];
 }
 
 CocoaInitializer::~CocoaInitializer()
 {
-	[d->autoReleasePool_ release];
-        [c->autoReleasePool_ release];
-	delete c;
-	delete d;
+    [c->pool release];
+    delete c;
 }
--- a/QTfrontend/InstallController.h	Sun Apr 03 19:26:53 2011 +0400
+++ b/QTfrontend/InstallController.h	Sun Apr 03 19:27:48 2011 +0400
@@ -20,11 +20,11 @@
 #define INSTALLCONTROLLER_H
 
 class InstallController
-        {
+{
     public:
         virtual ~InstallController();
 
         virtual void showInstallController() = 0;
-        };
+};
 
 #endif
--- a/QTfrontend/M3Panel.h	Sun Apr 03 19:26:53 2011 +0400
+++ b/QTfrontend/M3Panel.h	Sun Apr 03 19:27:48 2011 +0400
@@ -22,7 +22,7 @@
 #include "InstallController.h"
 
 class M3Panel : public InstallController
-        {
+{
     public:
         M3Panel(void);
         ~M3Panel();
@@ -32,6 +32,6 @@
     private:
         class Private;
         Private* c;
-        };
+};
 
 #endif
--- a/QTfrontend/M3Panel.mm	Sun Apr 03 19:26:53 2011 +0400
+++ b/QTfrontend/M3Panel.mm	Sun Apr 03 19:27:48 2011 +0400
@@ -23,26 +23,25 @@
 
 class M3Panel::Private
 {
-public:
+    public:
         M3InstallController *install;
 };
 
 M3Panel::M3Panel(void)
 {
-	c = new Private;
+    c = new Private;
 
-	c->install = [[M3InstallController alloc] init];
-	[c->install retain];
-
+    c->install = [[M3InstallController alloc] init];
+    [c->install retain];
 }
 
 M3Panel::~M3Panel()
 {
-	[c->install release];
-	delete c;
+    [c->install release];
+    delete c;
 }
 
 void M3Panel::showInstallController()
 {
-        [c->install displayInstaller];
+    [c->install displayInstaller];
 }
--- a/QTfrontend/SparkleAutoUpdater.mm	Sun Apr 03 19:26:53 2011 +0400
+++ b/QTfrontend/SparkleAutoUpdater.mm	Sun Apr 03 19:27:48 2011 +0400
@@ -1,7 +1,23 @@
 /*
- * Copyright (C) 2008 Remko Troncon
+ * Hedgewars, a free turn based strategy game
+ * Copyright (c) 2005-2011 Andrey Korotaev <unC0Rr@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  */
 
+// see original example here http://el-tramo.be/blog/mixing-cocoa-and-qt
+
 #include "SparkleAutoUpdater.h"
 
 #include <Cocoa/Cocoa.h>
@@ -9,29 +25,28 @@
 
 class SparkleAutoUpdater::Private
 {
-	public:
-		SUUpdater* updater;
+    public:
+        SUUpdater* updater;
 };
 
 SparkleAutoUpdater::SparkleAutoUpdater(const QString& aUrl)
 {
-	d = new Private;
+    d = new Private;
 
-	d->updater = [SUUpdater sharedUpdater];
-	[d->updater retain];
+    d->updater = [SUUpdater sharedUpdater];
+    [d->updater retain];
 
-	NSURL* url = [NSURL URLWithString:
-			[NSString stringWithUTF8String: aUrl.toUtf8().data()]];
-	[d->updater setFeedURL: url];
+    NSURL* url = [NSURL URLWithString:[NSString stringWithUTF8String:aUrl.toUtf8().data()]];
+    [d->updater setFeedURL:url];
 }
 
 SparkleAutoUpdater::~SparkleAutoUpdater()
 {
-	[d->updater release];
-	delete d;
+    [d->updater release];
+    delete d;
 }
 
 void SparkleAutoUpdater::checkForUpdates()
 {
-	[d->updater checkForUpdatesInBackground];
+    [d->updater checkForUpdatesInBackground];
 }
--- a/QTfrontend/hwform.cpp	Sun Apr 03 19:26:53 2011 +0400
+++ b/QTfrontend/hwform.cpp	Sun Apr 03 19:27:48 2011 +0400
@@ -61,7 +61,6 @@
 #include "drawmapwidget.h"
 
 #ifdef __APPLE__
-#include "CocoaInitializer.h"
 #include "M3Panel.h"
 #ifdef SPARKLE_ENABLED
 #define SPARKLE_APPCAST_URL "http://www.hedgewars.org/download/appcast.xml"
@@ -101,7 +100,7 @@
 
 #ifdef SPARKLE_ENABLED
     AutoUpdater* updater;
-    CocoaInitializer initializer;
+
     updater = new SparkleAutoUpdater(SPARKLE_APPCAST_URL);
     if (updater && config->isAutoUpdateEnabled())
         updater->checkForUpdates();
--- a/QTfrontend/main.cpp	Sun Apr 03 19:26:53 2011 +0400
+++ b/QTfrontend/main.cpp	Sun Apr 03 19:27:48 2011 +0400
@@ -31,6 +31,9 @@
 #ifdef _WIN32
 #include <Shlobj.h>
 #endif
+#ifdef __APPLE__
+#include "CocoaInitializer.h"
+#endif
 
 bool checkForDir(const QString & dir)
 {
@@ -425,6 +428,10 @@
         registry_hklm.setValue("Software/Hedgewars/Path", bindir->absolutePath().replace("/", "\\"));
     }
 #endif
+#ifdef __APPLE__
+    // this creates the autoreleasepool that prevents leaking
+    CocoaInitializer initializer;
+#endif
 
     HWForm *Form = new HWForm();
 
--- a/tools/CMakeLists.txt	Sun Apr 03 19:26:53 2011 +0400
+++ b/tools/CMakeLists.txt	Sun Apr 03 19:27:48 2011 +0400
@@ -28,6 +28,7 @@
 	string(REGEX REPLACE "(.*)/include.*" "\\1" qt_base_dir "${QT_INCLUDE_DIR}")
 	find_program(macdeployqt_EXE NAMES macdeployqt macdeployqt-mac PATHS ${qt_base_dir}/bin NO_DEFAULT_PATH)
 
+	#this tool is present in qt 4.5 but only if you compile from sources; from qt 4.6 is present also in the binary version
 	if(NOT macdeployqt_EXE)
 		message(FATAL_ERROR "The utility macdeployqt is required to create the bundle!")
 	endif()
--- a/tools/CreateMacBundle.cmake.in	Sun Apr 03 19:26:53 2011 +0400
+++ b/tools/CreateMacBundle.cmake.in	Sun Apr 03 19:27:48 2011 +0400
@@ -2,11 +2,10 @@
 
 execute_process(COMMAND ls ${frameworks_dir} RESULT_VARIABLE doBundle OUTPUT_QUIET ERROR_QUIET)
 
-if(doBundle EQUAL 1)
-    execute_process(COMMAND mkdir -p ${frameworks_dir})
+execute_process(COMMAND mkdir -p ${frameworks_dir})
+execute_process(COMMAND ${macdeployqt_EXE} ${CMAKE_BINARY_DIR}/${bundle_name} OUTPUT_QUIET ERROR_QUIET)
 
-    execute_process(COMMAND ${macdeployqt_EXE} ${CMAKE_BINARY_DIR}/${bundle_name} OUTPUT_QUIET ERROR_QUIET)
-
+if(doBundle EQUAL 1)
     execute_process(COMMAND cp -pPR ${sdl_dir}          ${CMAKE_BINARY_DIR}/${frameworks_dir}/SDL.framework)
     execute_process(COMMAND cp -pPR ${SDLIMAGE_LIBRARY} ${CMAKE_BINARY_DIR}/${frameworks_dir}/SDL_image.framework)
     execute_process(COMMAND cp -pPR ${SDLNET_LIBRARY}   ${CMAKE_BINARY_DIR}/${frameworks_dir}/SDL_net.framework)