M
M
Max Suprunenko2015-10-23 10:10:29
C++ / C#
Max Suprunenko, 2015-10-23 10:10:29

Why does Windows issue "Program termination" on SDL_MOUSEMOTION event?

Why does Windows issue "Program termination" on SDL_MOUSEMOTION event?
Here is some source code of the event handler function

SDL_Event event;
  while (SDL_PollEvent(&event))
  {
    switch (event.type)
    {
    case SDL_QUIT:
      running = false;
    case SDL_MOUSEMOTION:
      mousePosition->setX(event.motion.x);
      mousePosition->setY(event.motion.y);
      break;
    default:
      break;
    }

from code from coordinates
#pragma once

class Vector2d
{
public:

  //Vector2d(float m_x, float m_y) : x(x_m), y(y_m) {}
  Vector2d()
  {
    x = 0;
    y = 0;
  }
  // Get coordinates //
  const float getX() { return x; }
  const float getY() { return y; }
  // Set our coordinates //
  void setX(float m_x) { x = m_x; }
  void setY(float m_y) { y = m_y; }
  
  float x;
  float y;
};

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
GavriKos, 2015-10-23
@msuprunenko

Debager in the teeth and go. Most likely you have either mousePosition == null or mousePosition->setX triggers the same event (SDL_MOUSEMOTION) and you get an infinite loop + stack overflow.
Generally if run in debug mode. then the error will become much more informative.
And you also have an explicit error mousePosition->setX(event.motion.y); - here probably setY. But that's off topic...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question