Commit d1dc5af4 authored by Ronan's avatar Ronan
Browse files

fix(c-wrapper): return correctly cObject in getCBackPtr

parent bd11c098
...@@ -153,22 +153,22 @@ public: ...@@ -153,22 +153,22 @@ public:
// Macro helpers. // Macro helpers.
template<typename T> template<typename T>
static T *getCppPtr (const std::shared_ptr<T> &cppObject) { static inline T *getCppPtr (const std::shared_ptr<T> &cppObject) {
return cppObject.get(); return cppObject.get();
} }
template<typename T> template<typename T>
static T *getCppPtr (T *cppObject) { static inline T *getCppPtr (T *cppObject) {
return cppObject; return cppObject;
} }
template<typename T> template<typename T>
static const T *getCppPtr (const std::shared_ptr<const T> &cppObject) { static inline const T *getCppPtr (const std::shared_ptr<const T> &cppObject) {
return cppObject.get(); return cppObject.get();
} }
template<typename T> template<typename T>
static const T *getCppPtr (const T *cppObject) { static inline const T *getCppPtr (const T *cppObject) {
return cppObject; return cppObject;
} }
...@@ -183,14 +183,14 @@ public: ...@@ -183,14 +183,14 @@ public:
static inline typename CppTypeToCType<CppType>::type *getCBackPtr (const std::shared_ptr<CppType> &cppObject) { static inline typename CppTypeToCType<CppType>::type *getCBackPtr (const std::shared_ptr<CppType> &cppObject) {
typedef typename CppTypeToCType<CppType>::type RetType; typedef typename CppTypeToCType<CppType>::type RetType;
Variant v = cppObject->getProperty("LinphonePrivate::Wrapper::cBackPtr"); Variant variant = cppObject->getProperty("LinphonePrivate::Wrapper::cBackPtr");
void *value = v.getValue<void *>(); void *value = variant.getValue<void *>();
if (!value) { if (value)
RetType *cObject = CObjectInitializer<CppType>::init(); return reinterpret_cast<RetType *>(value);
setCppPtrFromC(cObject, cppObject);
}
return reinterpret_cast<RetType *>(value); RetType *cObject = CObjectInitializer<CppType>::init();
setCppPtrFromC(cObject, cppObject);
return cObject;
} }
template< template<
...@@ -202,12 +202,12 @@ public: ...@@ -202,12 +202,12 @@ public:
Variant v = cppObject->getProperty("LinphonePrivate::Wrapper::cBackPtr"); Variant v = cppObject->getProperty("LinphonePrivate::Wrapper::cBackPtr");
void *value = v.getValue<void *>(); void *value = v.getValue<void *>();
if (!value) { if (value)
RetType *cObject = CObjectInitializer<CppType>::init(); return reinterpret_cast<RetType *>(value);
setCppPtrFromC(cObject, cppObject);
}
return reinterpret_cast<RetType *>(value); RetType *cObject = CObjectInitializer<CppType>::init();
setCppPtrFromC(cObject, cppObject);
return cObject;
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment