Skip to content

Commit

Permalink
fix: use qobject_cast in get
Browse files Browse the repository at this point in the history
qwobject_cast::get should ensure the cast is right. Use qobject_cast
here not static_cast.
  • Loading branch information
asterwyx authored and zccrs committed Sep 5, 2024
1 parent 3ca0b89 commit cf6195a
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/qwobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class qw_object : public qw_object_basic
}

static QW_ALWAYS_INLINE Derive *get(Handle *handle) {
return static_cast<Derive*>(map.value(handle));
return qobject_cast<Derive*>(map.value(handle));
}

static QW_ALWAYS_INLINE Derive *from(Handle *handle) {
Expand Down Expand Up @@ -212,5 +212,4 @@ struct qw_signal_##name { \
}; \
qw_signal_##name _signal_##name = this; \


QW_END_NAMESPACE

0 comments on commit cf6195a

Please sign in to comment.