mirror of
https://github.com/Relintai/sfw.git
synced 2024-11-08 07:52:09 +01:00
Fixed automatic Ref<> to Variant conversions.
This commit is contained in:
parent
96ae4a1f7e
commit
bb7ebfe362
@ -2,8 +2,8 @@
|
||||
|
||||
#include "render_core/application.h"
|
||||
|
||||
#include "render_core/3rd_glad.h"
|
||||
#include "core/memory.h"
|
||||
#include "render_core/3rd_glad.h"
|
||||
#include "render_core/mesh_utils.h"
|
||||
|
||||
void GameScene::event() {
|
||||
@ -104,7 +104,6 @@ void GameScene::render() {
|
||||
rot += 0.01;
|
||||
|
||||
Ref<Image> d = texture->get_data();
|
||||
|
||||
texture->create_from_image(d);
|
||||
|
||||
camera->bind();
|
||||
|
@ -7,8 +7,9 @@
|
||||
/*************************************************************************/
|
||||
|
||||
#include "core/memory.h"
|
||||
#include "object/object.h"
|
||||
#include "core/safe_refcount.h"
|
||||
#include "object/object.h"
|
||||
#include "object/ref_ptr.h"
|
||||
|
||||
class Reference : public Object {
|
||||
SFW_OBJECT(Reference, Object);
|
||||
@ -169,6 +170,73 @@ public:
|
||||
ref(memnew(T));
|
||||
}
|
||||
|
||||
RefPtr get_ref_ptr() const {
|
||||
RefPtr refptr;
|
||||
Ref<Reference> *irr = reinterpret_cast<Ref<Reference> *>(refptr.get_data());
|
||||
*irr = *this;
|
||||
return refptr;
|
||||
};
|
||||
|
||||
operator Variant() const {
|
||||
return Variant(get_ref_ptr());
|
||||
}
|
||||
|
||||
void operator=(const RefPtr &p_refptr) {
|
||||
Ref<Reference> *irr = reinterpret_cast<Ref<Reference> *>(p_refptr.get_data());
|
||||
Reference *refb = irr->ptr();
|
||||
if (!refb) {
|
||||
unref();
|
||||
return;
|
||||
}
|
||||
Ref r;
|
||||
r.reference = Object::cast_to<T>(refb);
|
||||
ref(r);
|
||||
r.reference = nullptr;
|
||||
}
|
||||
|
||||
void operator=(const Variant &p_variant) {
|
||||
RefPtr refptr = p_variant;
|
||||
Ref<Reference> *irr = reinterpret_cast<Ref<Reference> *>(refptr.get_data());
|
||||
Reference *refb = irr->ptr();
|
||||
if (!refb) {
|
||||
unref();
|
||||
return;
|
||||
}
|
||||
Ref r;
|
||||
r.reference = Object::cast_to<T>(refb);
|
||||
ref(r);
|
||||
r.reference = nullptr;
|
||||
}
|
||||
|
||||
Ref(const Variant &p_variant) {
|
||||
RefPtr refptr = p_variant;
|
||||
Ref<Reference> *irr = reinterpret_cast<Ref<Reference> *>(refptr.get_data());
|
||||
reference = nullptr;
|
||||
Reference *refb = irr->ptr();
|
||||
if (!refb) {
|
||||
unref();
|
||||
return;
|
||||
}
|
||||
Ref r;
|
||||
r.reference = Object::cast_to<T>(refb);
|
||||
ref(r);
|
||||
r.reference = nullptr;
|
||||
}
|
||||
|
||||
Ref(const RefPtr &p_refptr) {
|
||||
Ref<Reference> *irr = reinterpret_cast<Ref<Reference> *>(p_refptr.get_data());
|
||||
reference = nullptr;
|
||||
Reference *refb = irr->ptr();
|
||||
if (!refb) {
|
||||
unref();
|
||||
return;
|
||||
}
|
||||
Ref r;
|
||||
r.reference = Object::cast_to<T>(refb);
|
||||
ref(r);
|
||||
r.reference = nullptr;
|
||||
}
|
||||
|
||||
Ref() {
|
||||
reference = nullptr;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user