Problems while printing in a standalone program

Hi.
I try to develop a simple graphic user interface to visualize and print some signal digital acquired. I try to develop using Kdeleop 3.1.1 under fedora core 3 using root 4.02/00.

my application is really simple, when a push one button on the Frame the member guiwindow::openfile() is executed.
this member calls another Object Member {VisEventsevent(index,20480); }that visualize a TGraph in the c1 Canvas.
When c1->Print(“p.ps”); is executed the program says a stack trace error…

where I wrong?

Thank’s
Matteo Sassi


guiwindows.h

#include <TQObject.h>
#include <RQ_OBJECT.h>

#include <TApplication.h>
#include <TBrowser.h>
#include <TGFrame.h>
#include <TGClient.h>
#include <TGButton.h>
#include <TGFileDialog.h>
#include <TGTextEditDialogs.h>

#include <TGraph.h>
#include <TStyle.h>
#include <TCanvas.h>
#include <TObject.h>
#include <TRootEmbeddedCanvas.h>
#include <TROOT.h>

/**
@author matteo sassi
*/
class guiwindow{

RQ_OBJECT(“guiwindow”)

protected:
TCanvas *c1;
TGMainFrame *fMain;
TRootEmbeddedCanvas *fCanvas;
int index;
char * filename;

public:
guiwindow(int x, int y);
~guiwindow();
void VisEventsevent(int index,int NoS);
void prova();
void prev();
void next();
void print();
void openfile();
};

#endif


member function

void guiwindow::openfile()
{
static const char NT[] = { “Sample Files”, ".smp",
“DatFiles”, “*.dat”,

                                0,               0 };
TGFileInfo *FI = new TGFileInfo();

FI->fFileTypes = NT;
FI->fIniDir = StrDup("/home/sax/lavoro/");
TGFileDialog *FD = new TGFileDialog(0, 0, kFDOpen,FI);
sprintf(filename,FI->fFilename);
index == 0;
gStyle->SetLineWidth(1);
VisEventsevent(index,20480);
c1->Print("p.ps");

}


Error

Generating stack trace…
0x0804df84 in guiwindow::openfile() + 0x10a from ./eventviewer
0x0804f72b in from ./eventviewer
0xf686ac67 in G__CallFunc::Exec(void*) + 0x71 from /usr/local/root/lib/root/libCint.so
0xf6aafbd6 in TQConnection::ExecuteMethod() + 0x6c from /usr/local/root/lib/root/libCore.so
0xf6ab2f3a in TQObject::Emit(char const*) + 0x300 from /usr/local/root/lib/root/libCore.so
0xf6244706 in TGButton::Clicked() + 0x26 from /usr/local/root/lib/root/libGui.so
0xf623f0d6 in TGButton::EmitSignals(bool) + 0x78 from /usr/local/root/lib/root/libGui.so
0xf623ee15 in TGButton::SetState(EButtonState, bool) + 0x8f from /usr/local/root/lib/root/libGui.so
0xf623efc7 in TGButton::HandleButton(Event_t*) + 0x131 from /usr/local/root/lib/root/libGui.so
0xf6271ac7 in TGFrame::HandleEvent(Event_t*) + 0x287 from /usr/local/root/lib/root/libGui.so
0xf6250744 in TGClient::HandleEvent(Event_t*) + 0xfe from /usr/local/root/lib/root/libGui.so
0xf6250376 in TGClient::ProcessOneEvent() + 0x74 from /usr/local/root/lib/root/libGui.so
0xf6250495 in TGClient::HandleInput() + 0x2d from /usr/local/root/lib/root/libGui.so
0xf624eb32 in TGInputHandler::Notify() + 0x1e from /usr/local/root/lib/root/libGui.so
0xf6baba55 in TUnixSystem::DispatchOneEvent(bool) + 0x65 from /usr/local/root/lib/root/libCore.so
0xf6acebce in TSystem::InnerLoop() + 0x18 from /usr/local/root/lib/root/libCore.so
0xf6aceb6e in TSystem::Run() + 0x7a from /usr/local/root/lib/root/libCore.so
0xf6a66e1e in TApplication::Run(bool) + 0x32 from /usr/local/root/lib/root/libCore.so
0x0804c3b6 in main + 0xa2 from ./eventviewer
0x00971e33 in __libc_start_main + 0xe3 from /lib/tls/libc.so.6
0x0804c181 in TApplicationImp::ShowMembers(TMemberInspector&, char*) + 0x31 from ./eventviewer

Hi Matteo,

Please check your case with the attached example. Do you have LinkDef for your class? For more details read ftp://root.cern.ch/root/doc/chapter13.pdf

Best regards, Ilka
sa_example.txt (2.82 KB)

Ok
I’ve tryed the example and works correcly.
Applying the change on my file, at the first time, the programs make the same error.
In a second time I’ve found the problem that interest the TCanvas *c1 pointer, that in haven’t a wrong value.

Now all work correclty.
Thank’s for your help

Best Regards

Matteo Sassi