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 { class Application {
public: public:
// static const int WINDOW_X = 1366; // static const int WINDOW_X = 1366;
// static const int WINDOW_Y = 768; // static const int WINDOW_Y = 768;
static const int WINDOW_X = 1920; static const int WINDOW_X = 1920;

@ -168,7 +168,7 @@ public:
virtual void render_gui() override; virtual void render_gui() override;
virtual void update_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); void setSpeed(float speed);
float getSpeed(); 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; virtual void render_gui() override;

@ -63,7 +63,7 @@ class WindowHandler : public VrEventSubscriber {
public: public:
WindowHandler(sf::RenderWindow *window) : window_ref(window) { }; 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) { if (event.get()->type == vr::Event::Closed) {
window_ref->close(); window_ref->close();

@ -87,7 +87,7 @@ public:
void remove_light(unsigned int light_index); 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: private:

@ -33,7 +33,7 @@ public:
void set_rgbi(sf::Vector4f rgbi); 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); void update(double delta_time);

@ -7,10 +7,28 @@
class VrEventPublisher; class VrEventPublisher;
/**
*
* VrEventSubscriber
*
* When inherited, the user must impliment a
*
*
*
*
*
*
*
*/
class VrEventSubscriber { class VrEventSubscriber {
public: public:
virtual ~VrEventSubscriber(); 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, vr::Event::EventType type);
void subscribe_to_publisher(VrEventPublisher* publisher, std::vector<vr::Event::EventType> type); void subscribe_to_publisher(VrEventPublisher* publisher, std::vector<vr::Event::EventType> type);
void unsubscribe(VrEventPublisher* publisher, vr::Event::EventType type); void unsubscribe(VrEventPublisher* publisher, vr::Event::EventType type);

@ -18,6 +18,11 @@ Application::Application() {
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_handle->~LightHandle();
//light_controller->~LightController(); //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) { if (event->type == vr::Event::KeyPressed) {

@ -94,7 +94,7 @@ int Camera::update(double delta_time) {
return 1; 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) { 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) {} if (event->type == vr::Event::KeyHeld) {}
else if (event->type == vr::Event::KeyPressed) {} else if (event->type == vr::Event::KeyPressed) {}

@ -68,7 +68,7 @@ void LightHandle::set_rgbi(sf::Vector4f rgbi)
data_reference->rgbi = 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) { 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]; //std::vector<VrEventSubscriber*> *event_type_bucket = &subscribers[event->type];
// Send them the event // 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 // will be a unique ptr solely owned by that function
for (auto s : subscribers[event->type]) { for (auto s : subscribers[event->type]) {
s->recieve_event(this, event->clone()); s->event_handler(this, event->clone());
} }
} }

Loading…
Cancel
Save