title: C++ sfml receives close event just after window opens
body: <p>I am trying to follow a SFML tutorial from this <a href="https://www.youtube.com/watch?v=kAbkFY6lwAY" rel="nofollow">link</a>, however, for some reason my application seems to be caling the close event as soon as my program enters into the event loop.</p>
  
  <p>Here is my code.</p>
  
  <pre><code>#include &lt;SFML/Graphics.hpp&gt;
  #include &lt;iostream&gt;
  
  // Here is a small helper for you ! Have a look.
  #include "ResourcePath.hpp"
  
  int main()
  {
  sf::RenderWindow Window(sf::VideoMode(500,400),"SFML tutorial");
  /* Or we can do this
   * sf::RenderWindow Window
   * Window.create (sf::VideoMode(800,600),"SFML tutorial");
   */
  
  //Game loop
  while(Window.isOpen())
  {
      sf::Event Event;
      while(Window.pollEvent(Event));
      {
          if(Event.type == sf::Event::Closed)
          {
              Window.close();
              std::cout &lt;&lt; "Close" &lt;&lt; std::endl;
  
          }
      }
  }
  
  return 0;
  </code></pre>
  
  <p>}</p>
  
  <p>For some reason as soon as my program enters the event loop it receives a sf::Event::Closed event. I have done some research and this is not because the window is too big for my screen. <br>
  To fix my issue I have had to ad a int variable <code>canClose</code> to 0 then modify the event loop to this.</p>
  
  <pre><code>if(Event.type == sf::Event::Closed)
  {
      if(canClose == 1)
      {
          Window.close();
      } else {
          canClose = 1;
      }
  }
  </code></pre>
  
  <p>After I do this the window now opens and runs as expected.</p>
  
  <p>P.S this is made using xcode and the SFML template.</p>
  
  <p><strong>Edit:</strong> <br>
  <strong>Just made a new xcode SFML project and removed some code in it to make a empty window and it seems to whork. Code looks exactly the same. This seams strange because it is exactly the same code.</strong></p>