fix: native object validate

This commit is contained in:
Nomango 2023-09-25 17:47:40 +08:00
parent b4f1f0f566
commit 4a5c2bdcb1
2 changed files with 7 additions and 4 deletions

View File

@ -106,25 +106,21 @@ public:
inline pointer_type operator->() inline pointer_type operator->()
{ {
KGE_ASSERT(ptr_ != nullptr && "Invalid pointer");
return ptr_; return ptr_;
} }
inline const_pointer_type operator->() const inline const_pointer_type operator->() const
{ {
KGE_ASSERT(ptr_ != nullptr && "Invalid pointer");
return ptr_; return ptr_;
} }
inline reference_type operator*() inline reference_type operator*()
{ {
KGE_ASSERT(ptr_ != nullptr && "Invalid pointer");
return *ptr_; return *ptr_;
} }
inline const_reference_type operator*() const inline const_reference_type operator*() const
{ {
KGE_ASSERT(ptr_ != nullptr && "Invalid pointer");
return *ptr_; return *ptr_;
} }

View File

@ -47,6 +47,8 @@ public:
void ResetNative(); void ResetNative();
bool IsValid() const override;
protected: protected:
Any native_; Any native_;
}; };
@ -86,4 +88,9 @@ inline void NativeObject::ResetNative()
native_.Clear(); native_.Clear();
} }
inline bool NativeObject::IsValid() const
{
return native_.HasValue() && ObjectBase::IsValid();
}
} // namespace kiwano } // namespace kiwano