TRootEmbeddedCanvas unhandled exception if not using theApp.Run()

Regarding the attached project I found that a row (made with GUIBuilder) make a runtime error if I don’t call theApp.Run() in the software

The error

unhandled exception in 0x00F6384B (libGui.dll) in OscilloC.exe: 0xC0000005:access violation while reading the path 0xFEEEFEF2.

The row

TRootEmbeddedCanvas *realtime = new TRootEmbeddedCanvas(0, fCompositeFrame671, 950, 520, kSunkenFrame, ucolor);

I want to make a custom loop inside my main function and to use gSystem->ProcessEvents(); to handle GUI only when needed. I tried to use theApp.Run(kTRUE) but it seems to be blocking.

Thanks

OscilloC.zip (20.2 KB)

Hi,

I cannot reproduce the problem…
EDIT: OK, sorry, I see. You must use theApp.Run() to have handle the events. Or use an infinite loop , like while (!gSystem->ProcessEvents()) {;}, but I really don’t see why you want to do it that way…

Cheers, Bertrand.

1 Like

Oh, sorry for the delay but i read your message from the mail and yesterday I reinstalled VS, root and root debug to try to solve the problem. :smiley:

With theApp.Run() I don’t have the problem, but with while (!gSystem->ProcessEvents()) {;} I have it.

I come from a py+pyQtGraph experience and I want to move to a more performing software; for that reason i prefer to manually update the UI and to have more free CPU for other tasks.

Since data must be read from serial and analyzed in real time no parallelization is needed. I read
https://root.cern.ch/doc/master/classTApplication.html#a49ee3476597351ae4c55e26d5a7d4e66
but I really didn’t get the point of the parameter.

Is there a simplier way to handle the UI only when needed?

Thanks

Then use theApp.Run()

Well, TApplication::Run() will only process pending events, and will not use any CPU time if there is no event to handle…

From my test TApplication::Run() block the code flow. If I run something like

theApp.Run();
cout << "test";

I never see the cout. The main idea is to do

while(theApp.IsRunning()) {
s.analyzeData(); // method that read all serial buffer
gSystem->ProcessEvents();
}

But I have the problem explained before

Try:

cout << "test";
theApp.Run();

Everything after theApp.Run(); is executed after returning from Run()

theApp.Run(); will NEVER return, theApp.Run(kTRUE); will (after you click “any canvas main menu” -> “File” -> “Quit ROOT”).

Yes, but i want to plot analyzed data in real time so I must link the UI and the serial analysis.

From my point of view i can’t see any advantage. My main goal is to analyze all data in the serial buffer and then plot results, then analyzing other received data and then plotting, etc. How can i achieve that?

In py I built a system with 2 thread but data arrays must be locked when accessed from the two thread (or to send “packets” of data between threads) so i think i loose more performance then what i gain.

So, since i want to improve maximum readable speed, i went to root & C++ thinking I should keep the serial analysis in the main thread and to reduce the use of resources.

Well, you can also use multi-threading in ROOT…
But anyway, you should be able to create a loop with calls to gSystem->ProcessEvents() without any problem. So I would debug this first…

OK, from my tests the problems happens if I complete the main function, without calling

gSystem->Exit(0); // or something similar

It’s probably related to something i start creating TRootEmbeddedCanvas that can’t end propely. I can also terminate the app calling gSystem->ProcessEvents() after that the console has beeen closed.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.