[Kst] branches/work/kst/portto4/kst/src
Peter Kümmel
syntheticpp at gmx.net
Sat Jan 1 11:52:37 CET 2011
SVN commit 1210606 by kuemmel:
also compile with GCC when using QSharedPointer
M +18 -9 libkst/sharedptr.h
M +4 -4 libkstmath/curve.cpp
--- branches/work/kst/portto4/kst/src/libkst/sharedptr.h #1210605:1210606
@@ -46,22 +46,31 @@
#ifdef KST_USE_QSHAREDPOINTER
+// In the final version SharedPtr should be completely replaced by QSharedPointer
+
template< class T >
struct SharedPtr : public QSharedPointer<T>
{
public:
- SharedPtr() : QSharedPointer() {}
- /*explicit*/SharedPtr(T* t) : QSharedPointer(t) {}
+ SharedPtr() {}
~SharedPtr() {}
- SharedPtr(int) : QSharedPointer() {}
- SharedPtr(const SharedPtr& p) : QSharedPointer(p) {}
- SharedPtr(const QSharedPointer& p) : QSharedPointer(p) {}
+ //explicit // TODO compile with 'explicit
+ SharedPtr(T* t) : QSharedPointer<T>(t) {}
+
+ // remove
+ explicit SharedPtr(int v) { Q_ASSERT(v==0); }
+ explicit SharedPtr(long int v) { Q_ASSERT(v==0); }
+
template<class Y>
- operator SharedPtr<Y>() const { return this->objectCast<Y>(); }
+ SharedPtr(const SharedPtr<Y>& p) { *this = p.template objectCast<T>(); }
+ SharedPtr(const SharedPtr& p) : QSharedPointer<T>(p) {}
+ SharedPtr(const QSharedPointer<T>& p) : QSharedPointer<T>(p) {}
- operator T*() const { return data(); }
- operator bool() const { return !isNull(); }
+ template<class Y>
+ operator SharedPtr<Y>() const { return this->template objectCast<Y>(); }
+ operator T*() const { return QSharedPointer<T>::data(); }
+ operator bool() const { return !QSharedPointer<T>::isNull(); }
};
#else
@@ -227,7 +236,7 @@
template <typename T, typename U>
inline SharedPtr<T> kst_cast(SharedPtr<U> object) {
#ifdef KST_USE_QSHAREDPOINTER
- return object.objectCast<T>();
+ return object.template objectCast<T>();
#else
return qobject_cast<T*>(object.data());
#endif
--- branches/work/kst/portto4/kst/src/libkstmath/curve.cpp #1210605:1210606
@@ -1098,10 +1098,10 @@
b_1 = benchtmp.elapsed();
#endif
- VectorPtr exv = _inputVectors.contains(EXVECTOR) ? *_inputVectors.find(EXVECTOR) : 0;
- VectorPtr eyv = _inputVectors.contains(EYVECTOR) ? *_inputVectors.find(EYVECTOR) : 0;
- VectorPtr exmv = _inputVectors.contains(EXMINUSVECTOR) ? *_inputVectors.find(EXMINUSVECTOR) : 0;
- VectorPtr eymv = _inputVectors.contains(EYMINUSVECTOR) ? *_inputVectors.find(EYMINUSVECTOR) : 0;
+ VectorPtr exv = _inputVectors.contains(EXVECTOR) ? *_inputVectors.find(EXVECTOR) : VectorPtr();
+ VectorPtr eyv = _inputVectors.contains(EYVECTOR) ? *_inputVectors.find(EYVECTOR) : VectorPtr();
+ VectorPtr exmv = _inputVectors.contains(EXMINUSVECTOR) ? *_inputVectors.find(EXMINUSVECTOR) : VectorPtr();
+ VectorPtr eymv = _inputVectors.contains(EYMINUSVECTOR) ? *_inputVectors.find(EYMINUSVECTOR) : VectorPtr();
// draw the bargraph bars, if any...
if (hasBars()) {
bool visible = true;
More information about the Kst
mailing list