[ox] Fix MC negative int encoding and bump MC version to 2

This commit is contained in:
2022-03-03 01:25:54 -06:00
parent bd2dd3f000
commit 6cebe52904
9 changed files with 126 additions and 68 deletions

View File

@@ -20,3 +20,9 @@ SignalHandler::~SignalHandler() noexcept {
}
}
/*
* 1. ProjectExplorer::fileOpened cannot notify StudioUI that it is being destroyed.
* 2. StudioUI tries to unsubscribe from ProjectExplorer::fileOpened upon its destruction.
* 3. Segfault
*/

View File

@@ -8,6 +8,8 @@
#pragma once
#include <ox/std/assert.hpp>
#include <ox/std/def.hpp>
#include <ox/std/defines.hpp>
#include <ox/std/error.hpp>
#include <ox/std/memory.hpp>
@@ -36,10 +38,6 @@ struct isError<Error> {
template<class... Args>
class Signal {
private:
template<typename T>
static constexpr void ignoreValue(const T&) {}
protected:
struct BaseSlot {
virtual ~BaseSlot() = default;
@@ -85,7 +83,10 @@ class Signal {
}
void cleanup(Signal *signal) noexcept final {
oxIgnoreError(m_receiver->destruction.disconnectSignal(signal));
auto err = m_receiver->destruction.disconnectSignal(signal);
if (err) {
oxErrorf("Signal could not notify receiver that it is being destroyed. Destruction of receiver will cause use-after-free. ({})", toStr(err));
}
}
[[nodiscard]]
@@ -196,7 +197,7 @@ Error Signal<Args...>::disconnectObject(const void *receiver) const noexcept {
--i;
}
}
return OxError(0);
return OxError(1, "Signal::disconnectObject: Receiver was not found among this Signal's slots");
}
template<class... Args>
@@ -263,7 +264,9 @@ class Signal<Error(Args...)> {
}
void cleanup(Signal *signal) noexcept final {
oxIgnoreError(m_receiver->destruction.disconnectSignal(signal));
auto err = m_receiver->destruction.disconnectSignal(signal);
oxErrorf("{}", toStr(err));
//oxAssert(err, "Signal could not notify receiver that it is being destroyed. Destruction of receiver will cause use-after-free.");
}
[[nodiscard]]
@@ -327,6 +330,11 @@ class SignalHandler {
public:
Signal<Error(const SignalHandler*)> destruction;
constexpr SignalHandler() noexcept = default;
SignalHandler(const SignalHandler&) = delete;
SignalHandler(SignalHandler&) = delete;
SignalHandler(SignalHandler&&) = delete;
virtual ~SignalHandler() noexcept;
};
@@ -377,7 +385,7 @@ Error Signal<Error(Args...)>::disconnectObject(const void *receiver) const noexc
--i;
}
}
return OxError(0);
return OxError(1, "Signal::disconnectObject: Receiver was not found among this Signal's slots");
}
template<class... Args>