How to close root session without a crash?

Hi!

I’m trying to close application, but every command I’ve tried causes a crash.
Do you know how I can elegantly close the root session and program?

I’ve tried this commands, and they didn’t work:

[ul]
[li]gSystem->Exit(0);[/li]
[li]gSystem->ExitLoop();[/li]
[li]fMainFrame990->Cleanup();
delete fMainFrame990;[/li]
[li]gEve->GetBrowser()->GetMainFrame()->CloseWindow();[/li]
[li]gApplication->Terminate();[/li]
[li]gApplication->Terminate(0);[/li]
[li]exit(0);[/li]
[li]gSystem->Abort();[/li][/ul]

all of them caused a crash!!

Also, I’ve seen similar posts on the forum but I didn’t see a valid solution. Can you please help me?

Thank you very much!

Have a look how it’s done in ROOT?
try:

[quote=“tpochep”]Have a look how it’s done in ROOT?
try:

I’ve added that as an command that didn’t work, because it’s not working and it causes a crash :frowning:
Is there maybe any alternative?

[quote=“AryaStark”][quote=“tpochep”]Have a look how it’s done in ROOT?
try:

I’ve added that as an command that didn’t work, because it’s not working and it causes a crash :frowning:
Is there maybe any alternative?[/quote]

What do you mean by “causes a crash”? I’ve no idea what code you have, but a simple one line command gApplication->Terminate(0); is what quits ROOT. Without all other lines you have. ONLY THIS ONE.

Here:

root.cern.ch/gitweb?p=root.git;a … 328b7d2b24

the line 1833 - this is what happens when you select “File”->“Quit” in TBrowser, for example. Please note, only gApplication->Terminate(0); nothing else. Of course, if you have some bugs in your application, even this can lead to crash, but you have to provide more information about your crash then or better try to debug it (since it’s quite difficult to debug in a “forum mode”).

1 Like

I’ve tried with just that one line. My method looks like this:

void launcher:: Exit()
{
 	gApplication->Terminate(0);
}

and when i call it, my program crashes. :frowning:

I see that this guy: goo.gl/xjmUr4 had the same problem as me, but there was no solution :’(

[quote=“AryaStark”]
I see that this guy: goo.gl/xjmUr4 had the same problem as me, but there was no solution :’([/quote]

Hmm, the solution exists though I’m afraid it can be quite painful - just build ROOT/your application in debug mode and fix the bug(s). gApplication->Terminate(0); is what terminates ROOT and can be found in many WORKING (== no crashes) applications/GUI examples, and you can just try this call in a command line, for example.