Fixed the most common crash on exit, still one more hiding and crashing in libc

master
mitchellhansen 7 years ago
parent d6bdcbdeca
commit c17d937ee5

@ -41,6 +41,7 @@ class CLCaster;
class Application {
public:
// static const int WINDOW_X = 1366;
// static const int WINDOW_Y = 768;
static const int WINDOW_X = 1920;

@ -168,7 +168,7 @@ public:
virtual void render_gui() override;
virtual void update_gui() override;
virtual void recieve_event(VrEventPublisher* publisher, std::unique_ptr<vr::Event> event) override;
virtual void event_handler(VrEventPublisher *publisher, std::unique_ptr<vr::Event> event) override;
// ================================

@ -57,7 +57,7 @@ public:
void setSpeed(float speed);
float getSpeed();
void recieve_event(VrEventPublisher* publisher, std::unique_ptr<vr::Event> event) override;
void event_handler(VrEventPublisher *publisher, std::unique_ptr<vr::Event> event) override;
virtual void render_gui() override;

@ -63,7 +63,7 @@ class WindowHandler : public VrEventSubscriber {
public:
WindowHandler(sf::RenderWindow *window) : window_ref(window) { };
virtual void recieve_event(VrEventPublisher* publisher, std::unique_ptr<vr::Event>(event)) override {
virtual void event_handler(VrEventPublisher *publisher, std::unique_ptr<vr::Event>(event)) override {
if (event.get()->type == vr::Event::Closed) {
window_ref->close();

@ -87,7 +87,7 @@ public:
void remove_light(unsigned int light_index);
void recieve_event(VrEventPublisher* publisher, std::unique_ptr<vr::Event> event) override;
void event_handler(VrEventPublisher *publisher, std::unique_ptr<vr::Event> event) override;
private:

@ -33,7 +33,7 @@ public:
void set_rgbi(sf::Vector4f rgbi);
virtual void recieve_event(VrEventPublisher* publisher, std::unique_ptr<vr::Event> event) override;
virtual void event_handler(VrEventPublisher *publisher, std::unique_ptr<vr::Event> event) override;
void update(double delta_time);

@ -7,10 +7,28 @@
class VrEventPublisher;
/**
*
* VrEventSubscriber
*
* When inherited, the user must impliment a
*
*
*
*
*
*
*
*/
class VrEventSubscriber {
public:
virtual ~VrEventSubscriber();
virtual void recieve_event(VrEventPublisher* publisher, std::unique_ptr<vr::Event> event) = 0;
virtual void event_handler(VrEventPublisher *publisher, std::unique_ptr<vr::Event> event) = 0;
void subscribe_to_publisher(VrEventPublisher* publisher, vr::Event::EventType type);
void subscribe_to_publisher(VrEventPublisher* publisher, std::vector<vr::Event::EventType> type);
void unsubscribe(VrEventPublisher* publisher, vr::Event::EventType type);

@ -18,6 +18,11 @@ Application::Application() {
Application::~Application() {
if (window.unique())
window.reset();
else {
Logger::log("Can't release window, shared_ptr coun : " + window.use_count(), Logger::LogLevel::WARN);
}
//light_handle->~LightHandle();
//light_controller->~LightController();
}

@ -370,7 +370,7 @@ void CLCaster::update_gui() {
}
void CLCaster::recieve_event(VrEventPublisher* publisher, std::unique_ptr<vr::Event> event) {
void CLCaster::event_handler(VrEventPublisher *publisher, std::unique_ptr<vr::Event> event) {
if (event->type == vr::Event::KeyPressed) {

@ -94,7 +94,7 @@ int Camera::update(double delta_time) {
return 1;
}
void Camera::recieve_event(VrEventPublisher* publisher, std::unique_ptr<vr::Event> event) {
void Camera::event_handler(VrEventPublisher *publisher, std::unique_ptr<vr::Event> event) {
if (event->type == vr::Event::KeyHeld) {

@ -36,7 +36,7 @@ void LightController::remove_light(unsigned int light_index) {
}
void LightController::recieve_event(VrEventPublisher* publisher, std::unique_ptr<vr::Event> event) {
void LightController::event_handler(VrEventPublisher *publisher, std::unique_ptr<vr::Event> event) {
if (event->type == vr::Event::KeyHeld) {}
else if (event->type == vr::Event::KeyPressed) {}

@ -68,7 +68,7 @@ void LightHandle::set_rgbi(sf::Vector4f rgbi)
data_reference->rgbi = rgbi;
}
void LightHandle::recieve_event(VrEventPublisher* publisher, std::unique_ptr<vr::Event> event)
void LightHandle::event_handler(VrEventPublisher *publisher, std::unique_ptr<vr::Event> event)
{
if (event->type == vr::Event::JoystickMoved) {

@ -74,10 +74,10 @@ void VrEventPublisher::notify_subscribers(std::unique_ptr<vr::Event> event) {
//std::vector<VrEventSubscriber*> *event_type_bucket = &subscribers[event->type];
// Send them the event
// Each and every event that is received in the recieve_event function
// Each and every event that is received in the event_handler function
// will be a unique ptr solely owned by that function
for (auto s : subscribers[event->type]) {
s->recieve_event(this, event->clone());
s->event_handler(this, event->clone());
}
}

Loading…
Cancel
Save