summaryrefslogtreecommitdiffstats
path: root/audio/kmix/files/patch-libcxx
blob: 61dbd8ab54176cc5f3bbcdc657ae0136c8ae3981 (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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
commit f184967a01381ca43a02d44edf3158e6cc0be376
Author: Raphael Kubo da Costa <rakuco@FreeBSD.org>
Date:   Tue Sep 3 12:55:39 2013 +0300

    Properly detect the location of STL's shared_ptr.

    std::shared_ptr is a C++11 feature, whose location (and existence) in STL
    implementations of previous C++ standards varied -- one widespread example
    is GCC's libstdc++, which has a shared_ptr implementation in <tr1/memory>
    that was shipped long before C++11.

    However, including it unconditionally breaks the build if any other STL
    implementation (such as libc++) is used instead.

    We now check if std::shared_ptr is present in the <memory> header and then
    try std::tr1::shared_ptr as a fallback.

    REVIEW:             112434

commit 111de2e86a3a79d43744e7d76a5a0be1d6e8fe0d
Author: Raphael Kubo da Costa <rakuco@FreeBSD.org>
Date:   Tue Sep 3 12:54:48 2013 +0300

    Use operator bool() instead of != and == for shared_ptr.

    (This is part 1 of 2 of the shared_ptr changes)

    In preparation for supporting C++11's version of shared_ptr, convert
    some
    comparisons to operator bool(), that is

      if (foo != 0) becomes if (foo)
      if (foo == 0) becomes if (!foo)

    as otherwise the build (with clang and libc++) would fail because there is
    no overload for operator==(shared_ptr, int) and operator!=(shared_ptr, int).

    REVIEW:             112433

diff --git a/CMakeLists.txt b/CMakeLists.txt
index a442972..1f75530 100644
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -26,6 +26,17 @@ if(MSVC)
 endif(MSVC)
 
 
+include(CheckCXXSourceCompiles)
+check_cxx_source_compiles("
+    #include <memory>
+    int main() { std::shared_ptr<int> p; return 0; }
+" HAVE_STD_SHARED_PTR)
+check_cxx_source_compiles("
+    #include <tr1/memory>
+    int main() { std::tr1::shared_ptr<int> p; return 0; }
+" HAVE_STD_TR1_SHARED_PTR)
+
+
 configure_file (config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h )
 
 
diff --git a/apps/kmixd.cpp b/apps/kmixd.cpp
index 442abaf..9385a6a 100644
--- apps/kmixd.cpp
+++ apps/kmixd.cpp
@@ -156,7 +156,7 @@ void KMixD::saveBaseConfig()
       config.writeEntry( "MasterMixer", mixerMasterCard->id() );
    }
    shared_ptr<MixDevice> mdMaster = Mixer::getGlobalMasterMD();
-   if ( mdMaster != 0 ) {
+   if ( mdMaster ) {
       config.writeEntry( "MasterMixerDevice", mdMaster->id() );
    }
    QString mixerIgnoreExpression = MixerToolBox::instance()->mixerIgnoreExpression();
diff --git a/backends/mixer_backend.cpp b/backends/mixer_backend.cpp
index 2e2e901..2105d2a 100644
--- backends/mixer_backend.cpp
+++ backends/mixer_backend.cpp
@@ -241,7 +241,7 @@ void Mixer_Backend::readSetFromHW()
  */
 shared_ptr<MixDevice> Mixer_Backend::recommendedMaster()
 {
-	if ( m_recommendedMaster != 0 )
+	if ( m_recommendedMaster )
 	{
 		// Backend has set a recommended master. Thats fine. Using it.
 		return m_recommendedMaster;
diff --git a/backends/mixer_mpris2.cpp b/backends/mixer_mpris2.cpp
index 6ebcd8f..75ef129 100644
--- backends/mixer_mpris2.cpp
+++ backends/mixer_mpris2.cpp
@@ -535,7 +535,7 @@ void Mixer_MPRIS2::newMediaPlayer(QString name, QString oldOwner, QString newOwn
 			}
 
 			shared_ptr<MixDevice> md = m_mixDevices.get(id);
-			if (md != 0)
+			if (md)
 			{
 				// We know about the player that is unregistering => remove internally
 				md->close();
diff --git a/config.h.cmake b/config.h.cmake
index 032f8c1..acd9a9c 100644
--- config.h.cmake
+++ config.h.cmake
@@ -15,3 +15,9 @@
 
 /* Define to 1 if you have the <unistd.h> header file. */
 #cmakedefine HAVE_UNISTD_H 1
+
+/* Define to 1 if <tr1/memory> exists and defines std::tr1::shared_ptr. */
+#cmakedefine HAVE_STD_TR1_SHARED_PTR 1
+
+/* Define to 1 if <memory> exists and defines std::shared_ptr. */
+#cmakedefine HAVE_STD_SHARED_PTR 1
diff --git a/core/ControlPool.h b/core/ControlPool.h
index 4cb2222..b045ce0 100644
--- core/ControlPool.h
+++ core/ControlPool.h
@@ -22,12 +22,15 @@
 #ifndef CONTROL_POOL_H
 #define CONTROL_POOL_H
 
+#include "config.h"
 
-// std::shared_ptr
+#if defined(HAVE_STD_SHARED_PTR)
 #include <memory>
+using std::shared_ptr;
+#elif defined(HAVE_STD_TR1_SHARED_PTR)
 #include <tr1/memory>
-
-using namespace ::std::tr1;
+using std::tr1::shared_ptr;
+#endif
 
 #include "core/mixdevice.h"
 
diff --git a/core/MasterControl.h b/core/MasterControl.h
index dff9e95..16472ff 100644
--- core/MasterControl.h
+++ core/MasterControl.h
@@ -8,12 +8,17 @@
 #ifndef MASTERCONTROL_H_
 #define MASTERCONTROL_H_
 
-#include <QString>
+#include "config.h"
 
-// std::shared_ptr
+#if defined(HAVE_STD_SHARED_PTR)
 #include <memory>
+using std::shared_ptr;
+#elif defined(HAVE_STD_TR1_SHARED_PTR)
 #include <tr1/memory>
-using namespace ::std::tr1;
+using std::tr1::shared_ptr;
+#endif
+
+#include <QString>
 
 class MasterControl
 {
diff --git a/core/mixdevice.h b/core/mixdevice.h
index f5ca782..fb554a2 100644
--- core/mixdevice.h
+++ core/mixdevice.h
@@ -21,10 +21,15 @@
 #ifndef MixDevice_h
 #define MixDevice_h
 
-// std::shared_ptr
+#include "config.h"
+
+#if defined(HAVE_STD_SHARED_PTR)
 #include <memory>
+using std::shared_ptr;
+#elif defined(HAVE_STD_TR1_SHARED_PTR)
 #include <tr1/memory>
-using namespace ::std::tr1;
+using std::tr1::shared_ptr;
+#endif
 
 //KMix
 class Mixer;
diff --git a/core/mixertoolbox.cpp b/core/mixertoolbox.cpp
index 60c9fc8..41386d4 100644
--- core/mixertoolbox.cpp
+++ core/mixertoolbox.cpp
@@ -248,13 +248,13 @@ void MixerToolBox::initMixerInternal(MultiDriverMode multiDriverMode, QList<QStr
 
    
     // Add a master device (if we haven't defined one yet)
-   if ( Mixer::getGlobalMasterMD(false) == 0 ) {
+   if ( !Mixer::getGlobalMasterMD(false) ) {
       // We have no master card yet. This actually only happens when there was
       // not one defined in the kmixrc.
       // So lets just set the first card as master card.
       if ( Mixer::mixers().count() > 0 ) {
     	  shared_ptr<MixDevice> master = Mixer::mixers().first()->getLocalMasterMD();
-         if ( master != 0 ) {
+         if ( master ) {
              QString controlId = master->id();
              Mixer::setGlobalMaster( Mixer::mixers().first()->id(), controlId, true);
          }
diff --git a/gui/kmixdockwidget.cpp b/gui/kmixdockwidget.cpp
index 47e8073..e84338e 100644
--- gui/kmixdockwidget.cpp
+++ gui/kmixdockwidget.cpp
@@ -215,7 +215,7 @@ void KMixDockWidget::updatePixmap()
 	shared_ptr<MixDevice> md = Mixer::getGlobalMasterMD();
 
     char newPixmapType;
-    if ( md == 0 )
+    if ( !md )
     {
         newPixmapType = 'e';
     }
@@ -405,7 +405,7 @@ void KMixDockWidget::contextMenuAboutToShow()
 void KMixDockWidget::updateDockMuteAction ( KToggleAction* dockMuteAction )
 {  
     shared_ptr<MixDevice> md = Mixer::getGlobalMasterMD();
-    if ( md != 0 && dockMuteAction != 0 )
+    if ( md && dockMuteAction != 0 )
     {
     	Volume& vol = md->playbackVolume().hasVolume() ? md->playbackVolume() : md->captureVolume();
     	bool isInactive =  vol.isCapture() ? !md->isRecSource() : md->isMuted();
diff --git a/gui/viewdockareapopup.cpp b/gui/viewdockareapopup.cpp
index 48411bd..45edc32 100644
--- gui/viewdockareapopup.cpp
+++ gui/viewdockareapopup.cpp
@@ -248,12 +248,12 @@ Application: KMix (kmix), signal: Segmentation fault
 	{
 //		kDebug() << "ADD? mixerId=" << mixer->id();
 		shared_ptr<MixDevice>dockMD = mixer->getLocalMasterMD();
-		if ( dockMD == 0 && mixer->size() > 0 )
+		if ( !dockMD && mixer->size() > 0 )
 		{
 			// If we have no dock device yet, we will take the first available mixer device.
 			dockMD = (*mixer)[0];
 		}
-		if ( dockMD != 0 )
+		if ( dockMD )
 		{
 //			kDebug() << "ADD? mixerId=" << mixer->id() << ", md=" << dockMD->id();
 			if ( !dockMD->isApplicationStream() && dockMD->playbackVolume().hasVolume())
OpenPOWER on IntegriCloud