summaryrefslogtreecommitdiffstats
path: root/src/qjson-1-static.patch
blob: 77f54e5800dd507ff38a400cec4c3d89c4ca026f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
This file is part of MXE.
See index.html for further information.

From 5c1a9928d925dacebb56f191fec349077c750dbf Mon Sep 17 00:00:00 2001
From: Mark Brand <mabrand@mabrand.nl>
Date: Fri, 23 Nov 2012 08:41:43 +0100
Subject: [PATCH 1/2] build as static lib

taken from:
http://sourceforge.net/mailarchive/forum.php?thread_name=4E1DBC0D.10000%40jrit.at&forum_name=qjson-devel

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 07d84c6..3aee52d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -31,6 +31,13 @@ SET(FRAMEWORK_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/Library/Frameworks"
 # (This will have no effect with CMake < 2.8)
 SET(QT_USE_IMPORTED_TARGETS TRUE)
 
+# For Static builds
+IF(LIBTYPE STREQUAL "STATIC")
+    ADD_DEFINITIONS("-DQJSON_STATIC")
+    ADD_DEFINITIONS("-DQT_NODLL")
+    SET(PKG_CONFIG_CFLAGS -DQJSON_STATIC ${PKG_CONFIG_CFLAGS})
+endif()
+
 # Find Qt4
 FIND_PACKAGE( Qt4 REQUIRED )
 
diff --git a/QJson.pc.in b/QJson.pc.in
index e4704bd..bf5fd01 100644
--- a/QJson.pc.in
+++ b/QJson.pc.in
@@ -8,4 +8,4 @@ Description: QJson is a qt-based library that maps JSON data to QVariant objects
 Version: @QJSON_LIB_MAJOR_VERSION@.@QJSON_LIB_MINOR_VERSION@.@QJSON_LIB_PATCH_VERSION@
 Requires: QtCore
 Libs: -L${libdir} -lqjson
-Cflags: -I${includedir}
\ No newline at end of file
+Cflags: -I${includedir} @PKG_CONFIG_CFLAGS@
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index e2e8a13..c164b04 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -15,7 +15,12 @@ qt4_wrap_cpp(qjson_MOC_SRCS ${qjson_MOC_HDRS})
 set (qjson_SRCS parser.cpp qobjecthelper.cpp json_scanner.cpp json_parser.cc parserrunnable.cpp serializer.cpp serializerrunnable.cpp)
 set (qjson_HEADERS parser.h parserrunnable.h qobjecthelper.h serializer.h serializerrunnable.h qjson_export.h)
 
-add_library (qjson SHARED ${qjson_SRCS} ${qjson_MOC_SRCS} ${qjson_HEADERS})
+IF(LIBTYPE STREQUAL "STATIC")
+    add_library (qjson STATIC ${qjson_SRCS} ${qjson_MOC_SRCS} ${qjson_HEADERS})
+else()
+    add_library (qjson SHARED ${qjson_SRCS} ${qjson_MOC_SRCS} ${qjson_HEADERS})
+endif()
+
 target_link_libraries( qjson ${QT_LIBRARIES})
 
 if(NOT android)
diff --git a/src/qjson_export.h b/src/qjson_export.h
index 9a807b9..7e6646a 100644
--- a/src/qjson_export.h
+++ b/src/qjson_export.h
@@ -23,7 +23,9 @@
 #include <QtCore/qglobal.h>
 
 #ifndef QJSON_EXPORT
-# if defined(QJSON_MAKEDLL)
+# ifdef QJSON_STATIC
+#  define QJSON_EXPORT
+# elif defined(QJSON_MAKEDLL)
    /* We are building this library */
 #  define QJSON_EXPORT Q_DECL_EXPORT
 # else
-- 
1.7.10.4


From dbe71952b8b91359172f7f253a7cc07c1e746443 Mon Sep 17 00:00:00 2001
From: Flavio Castelli <fcastelli@suse.com>
Date: Thu, 22 Nov 2012 21:19:15 +0100
Subject: [PATCH 2/2] Fix unsafe pointer usage in Serializer::serialize().

This fixes issue #3.
(cherry picked from commit 56701d72da8a57a64522ff455d7aa460033398a9)

diff --git a/ChangeLog b/ChangeLog
index fa16030..6ae4d9d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Thu Nov 22 21:20:11 CET 2012  Flavio Castelli <flavio@castelli.name>
+
+	* Fix unsafe pointer usage in Serializer::serialize()
+
 ----------------------------------------------------------------------
 Wed Nov 21 22:01:51 CET 2012  Flavio Castelli <flavio@castelli.name>
 
diff --git a/src/serializer.cpp b/src/serializer.cpp
index 4ff3d54..b88827d 100644
--- a/src/serializer.cpp
+++ b/src/serializer.cpp
@@ -368,12 +368,12 @@ void Serializer::serialize( const QVariant& v, QIODevice* io, bool* ok)
 
 QByteArray Serializer::serialize( const QVariant &v, bool *ok)
 {
+  bool _ok = true;
   d->errorMessage.clear();
 
   if (ok) {
     *ok = true;
   } else {
-    bool _ok = true;
     ok = &_ok;
   }
 
-- 
1.7.10.4