# ROOT (TApplication) crash on exist when using with SFML

**URL:** <https://root-forum.cern.ch/t/root-tapplication-crash-on-exist-when-using-with-sfml/35555>\
**Category:** Newbie\
**Created:** [August 7, 2019, 4:13pm UTC](https://root-forum.cern.ch/t/root-tapplication-crash-on-exist-when-using-with-sfml/35555 "2019-08-07T16:13:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![marty1885](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/marty1885/32/19232_2.png) [@marty1885](https://root-forum.cern.ch/u/marty1885)\
**Post date:** [August 7, 2019, 4:13pm UTC](https://root-forum.cern.ch/t/root-tapplication-crash-on-exist-when-using-with-sfml/35555/1 "2019-08-07T16:13:18Z")

</div>

Hi all,  
I was trying to use ROOT with SFML to display statistics while I do other GUI stuff. So I ended up with the following code.

```auto
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>

#include <TApplication.h>

int main(int argc, char** argv)
{
        sf::RenderWindow window(sf::VideoMode(1200, 720), "SFML with ROOT");

        TApplication root_app("rootapp", &argc, argv);
        gStyle->SetCanvasPreferGL(true);

        bool running = true;
        while(running) {
                sf::Event event;
                while (window.pollEvent(event)) {
                        if (event.type == sf::Event::Closed)
                                running = false;
                }

                window.clear(sf::Color(198, 209, 244));

                window.display();
        }
}

```

(Compile with `c++ main.cpp $(root-config --glibs --cflags) -lsfml-window -lsfml-system -o main`)

The application starts normally. But when I closed the SFML window and exits the application. A segfault is generated. Am I doing anything wrong?

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [August 8, 2019, 7:20am UTC](https://root-forum.cern.ch/t/root-tapplication-crash-on-exist-when-using-with-sfml/35555/2 "2019-08-08T07:20:13Z")

</div>

Where do you process the ROOT events (where do you call `gSystem->ProcessEvents()`)?
