Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions bindings/r/src/TRInterface.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ extern "C"
using namespace ROOT::R;
ClassImp(TRInterface)

static ROOT::R::TRInterface *gR = NULL;
static ROOT::R::TRInterface *gR = nullptr;
static Bool_t statusEventLoop;

TRInterface::TRInterface(const Int_t argc, const Char_t *argv[], const Bool_t loadRcpp, const Bool_t verbose,
Expand Down Expand Up @@ -53,7 +53,10 @@ TRInterface::TRInterface(const Int_t argc, const Char_t *argv[], const Bool_t lo

TRInterface::~TRInterface()
{
statusEventLoop = kFALSE;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should'nt this also contains

if (gR == this) gR = nullptr;

?

if (th) delete th;
if (fR) delete fR;
if (gR == this) gR = nullptr;
}

//______________________________________________________________________________
Expand Down Expand Up @@ -199,18 +202,16 @@ Bool_t TRInterface::Install(TString pkg, TString repos)
void TRInterface::ProcessEventsLoop()
{
if (!statusEventLoop) {
th = new TThread([](void */*args*/) {
while (kTRUE) {
if (gR) { // in case global object was freed
fd_set *fd;
Int_t usec = 10000;
fd = R_checkActivity(usec, 0);
R_runHandlers(R_InputHandlers, fd);
if (gSystem) gSystem->Sleep(100);
}
th = new TThread([](void */*args */) {
while (statusEventLoop) {
fd_set *fd;
Int_t usec = 10000;
fd = R_checkActivity(usec, 0);
R_runHandlers(R_InputHandlers, fd);
if (gSystem) gSystem->Sleep(100);
}
});
th->Run();
statusEventLoop = kTRUE;
th->Run();
}
}