Hi guys,
So I have a weird problem, so I have the following in a class
std::shared_ptr<gyroEngine::managers::InputManager> mp_inputManager;
...
void GyroEngine::startManagers() {
mp_inputManager = std::make_shared<gyroEngine::managers::InputManager>(*this);
}
That is all fine and dandy, it seems to be working as is, I'm not getting any faults or anything from doing that and mp_inputManager is getting initialised.
Here's where my issue is. In my InputManager class I have:
void InputManager::handleEvents() {
sf::Event event;
while(mp_engine->getWindow()->pollEvent(event)) {
switch(event.type) {
...
}
}
}
Which also seems ok. I have the following back in my GyroEngine class:
void GyroEngine::gameLoop() {
while(mp_window->isOpen()) {
mp_inputManager->handleEvents();
update();
render();
}
}
Here is where it gets interesting. When I start the program, I instantly get a Segmentation Fault and it's coming from mp_inputManager->handleEvents(). I know this because just before I inserted that function into the gameLoop(), I'd written a handleEvents() function into GyroEngine.
My getWindow() function is as follows:
const std::shared_ptr<sf::RenderWindow> getWindow() const { return mp_renderWindow; }
What could be causing me to get this segfault?