[olympic/keel] Fix some unsafe pointer accesses, disconnect signals on asset move
This commit is contained in:
parent
72e54da017
commit
9b11fa4e91
@ -120,8 +120,8 @@ class AssetRef: public ox::SignalHandler {
|
|||||||
oxIgnoreError(m_ctr->updated.disconnectObject(this));
|
oxIgnoreError(m_ctr->updated.disconnectObject(this));
|
||||||
}
|
}
|
||||||
m_ctr = h.m_ctr;
|
m_ctr = h.m_ctr;
|
||||||
m_ctr->updated.connect(&updated, &ox::Signal<ox::Error()>::emitCheckError);
|
|
||||||
if (m_ctr) {
|
if (m_ctr) {
|
||||||
|
m_ctr->updated.connect(&updated, &ox::Signal<ox::Error()>::emitCheckError);
|
||||||
m_ctr->incRefs();
|
m_ctr->incRefs();
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
@ -136,7 +136,10 @@ class AssetRef: public ox::SignalHandler {
|
|||||||
oxIgnoreError(m_ctr->updated.disconnectObject(this));
|
oxIgnoreError(m_ctr->updated.disconnectObject(this));
|
||||||
}
|
}
|
||||||
m_ctr = h.m_ctr;
|
m_ctr = h.m_ctr;
|
||||||
|
if (m_ctr) {
|
||||||
|
oxIgnoreError(m_ctr->updated.disconnectObject(&h));
|
||||||
m_ctr->updated.connect(this, &AssetRef::emitUpdated);
|
m_ctr->updated.connect(this, &AssetRef::emitUpdated);
|
||||||
|
}
|
||||||
h.m_ctr = nullptr;
|
h.m_ctr = nullptr;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@ -154,14 +157,13 @@ class AssetRef: public ox::SignalHandler {
|
|||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
constexpr AssetRef<T>::AssetRef(AssetContainer<T> const*c) noexcept: m_ctr(c) {
|
constexpr AssetRef<T>::AssetRef(AssetContainer<T> const*c) noexcept: m_ctr(c) {
|
||||||
if (c) {
|
if (m_ctr) {
|
||||||
c->updated.connect(this, &AssetRef::emitUpdated);
|
m_ctr->updated.connect(this, &AssetRef::emitUpdated);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
constexpr AssetRef<T>::AssetRef(AssetRef const&h) noexcept {
|
constexpr AssetRef<T>::AssetRef(AssetRef const&h) noexcept: m_ctr(h.m_ctr) {
|
||||||
m_ctr = h.m_ctr;
|
|
||||||
if (m_ctr) {
|
if (m_ctr) {
|
||||||
m_ctr->updated.connect(this, &AssetRef::emitUpdated);
|
m_ctr->updated.connect(this, &AssetRef::emitUpdated);
|
||||||
m_ctr->incRefs();
|
m_ctr->incRefs();
|
||||||
@ -171,7 +173,9 @@ constexpr AssetRef<T>::AssetRef(AssetRef const&h) noexcept {
|
|||||||
template<typename T>
|
template<typename T>
|
||||||
constexpr AssetRef<T>::AssetRef(AssetRef &&h) noexcept {
|
constexpr AssetRef<T>::AssetRef(AssetRef &&h) noexcept {
|
||||||
m_ctr = h.m_ctr;
|
m_ctr = h.m_ctr;
|
||||||
|
if (m_ctr) {
|
||||||
m_ctr->updated.connect(this, &AssetRef::emitUpdated);
|
m_ctr->updated.connect(this, &AssetRef::emitUpdated);
|
||||||
|
}
|
||||||
h.m_ctr = nullptr;
|
h.m_ctr = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user