I am trying to get a dialog window with this piece of code :
TGWindow* const WinDialog= new TGWindow() ;
TGMsgBox QuitDialog = new TGMsgBox(gClient->GetRoot(),WinDialog->GetMainFrame(),"Quit ?","Click OK to exit the script",kMBIconExclamation,kMBOk) ;
And I indeed get the dialog window but when I click the ‘OK’ button I get an segmentation violation error. I cannot find out why. Any idea ? ( I don’t usually use any GUI related stuff …)
First of all (this is only C++ and has nothing to do with GUI), use a pointer with operator new. e.g. instead of “TGMsgBox QuitDialog = new …”, use “TGMsgBox *QuitDialog = new …”:
TGMsgBox *QuitDialog = new TGMsgBox(gClient->GetRoot(),WinDialog->GetMainFrame(),"Quit ?","Click OK to exit the script",kMBIconExclamation,kMBOk);
Then you don’t need (and shouldn’t) create a new TGWindow. This format is sufficient:
TGMsgBox *QuitDialog = new TGMsgBox(gClient->GetRoot(), gClient->GetRoot(),"Quit ?","Click OK to exit the script", kMBIconExclamation, kMBOk);
Cheers, Bertrand.
I am having the same problem. I have the following line within my code.
The message box shows up at the proper time but I get a segmentation violation when I press the Dismiss Button. This doesn’t affect anything else in the program but I would much prefer not getting these errors. Here is the stack trace from the crash.
[quote]
*** Break *** segmentation violation
===========================================================
There was a crash (#7 0x00780a0d in SigHandler(ESignals) () from /usr/local/lib/root/libCore.so).
This is the entire stack trace of all threads:
#0 0x00e0d422 in __kernel_vsyscall () #1 0x01e457d3 in waitpid () from /lib/tls/i686/cmov/libc.so.6 #2 0x01de6de3 in ?? () from /lib/tls/i686/cmov/libc.so.6 #3 0x01da327d in system () from /lib/tls/i686/cmov/libpthread.so.0 #4 0x0077906d in TUnixSystem::Exec(char const*) ()
from /usr/local/lib/root/libCore.so #5 0x0077f5a5 in TUnixSystem::StackTrace() () from /usr/local/lib/root/libCore.so #6 0x007808ff in TUnixSystem::DispatchSignals(ESignals) ()
from /usr/local/lib/root/libCore.so #7 0x00780a0d in SigHandler(ESignals) () from /usr/local/lib/root/libCore.so #8 0x00776282 in sighandler(int) () from /usr/local/lib/root/libCore.so #9 #10 0x0806e4d3 in PrimaryVertexTab::executeAnalysis() () #11 0x0809a648 in G__PixelGUI_Dict_859_0_7(G__value*, char const*, G__param*, int)
() #12 0x00e819e8 in Cint::G__CallFunc::Execute(void*) ()
from /usr/local/lib/root/libCint.so #13 0x00739f2b in TCint::CallFunc_Exec(void*, void*) const ()
from /usr/local/lib/root/libCore.so #14 0x006ca27a in TQConnection::ExecuteMethod() ()
from /usr/local/lib/root/libCore.so #15 0x006d0512 in TQObject::Emit(char const*) ()
from /usr/local/lib/root/libCore.so #16 0x018012aa in TGButton::Clicked() () from /usr/local/lib/root/libGui.so #17 0x017f29f0 in TGButton::EmitSignals(bool) ()
from /usr/local/lib/root/libGui.so #18 0x017f28b2 in TGButton::SetState(EButtonState, bool) ()
from /usr/local/lib/root/libGui.so #19 0x017f4c9f in TGButton::HandleButton(Event_t*) ()
from /usr/local/lib/root/libGui.so #20 0x0184f24f in TGFrame::HandleEvent(Event_t*) ()
from /usr/local/lib/root/libGui.so #21 0x018101cb in TGClient::HandleEvent(Event_t*) ()
from /usr/local/lib/root/libGui.so #22 0x01810abc in TGClient::ProcessOneEvent() ()
from /usr/local/lib/root/libGui.so #23 0x01810b2d in TGClient::HandleInput() () from /usr/local/lib/root/libGui.so #24 0x01810b60 in TGInputHandler::Notify() () from /usr/local/lib/root/libGui.so #25 0x0077d2fd in TUnixSystem::DispatchOneEvent(bool) ()
from /usr/local/lib/root/libCore.so #26 0x006efc91 in TSystem::InnerLoop() () from /usr/local/lib/root/libCore.so #27 0x006f28c9 in TSystem::Run() () from /usr/local/lib/root/libCore.so #28 0x00689e07 in TApplication::Run(bool) () from /usr/local/lib/root/libCore.so #29 0x08065d26 in main ()
The lines below might hint at the cause of the crash.
If they do not help you then please submit a bug report at root.cern.ch/bugs. Please post the ENTIRE stack trace
from above as an attachment in addition to anything else
that might help us fixing this issue.
#10 0x0806e4d3 in PrimaryVertexTab::executeAnalysis() ()
===========================================================[/quote]
I am compiling my code with gcc on Ubuntu Linux 10.04. I have ROOT version 5.27.
Well, it seems to me the problem comes from PrimaryVertexTab::executeAnalysis()…
Do you use signal slots in your application? What is PrimaryVertexTab::executeAnalysis() doing?