Skip to content

Conversation

linev
Copy link
Member

@linev linev commented Sep 25, 2025

Follow up for #19978

Show how ClearOnClose can be used for RBrowser.
To get signal immediately with browser close,
one should change gEnv->SetValue("WebGui.ReconnectTmout", -1);

While pending connection can be removed after timeout, invoke clear on close at that moment
Use shorter timeout to restart some specific widget after pressing Ctrl-R.
For that specially mark such connection with the falg.
Default reconnect timeout will be 15 s
When reconnect timeout is negative,
closed connection will be immediately destoryed
So no new connection will be possible.
In that case cleanup handle will be invoked immediately
It directly calls fWebWinow->Sync() where pending actions can be performed.
Can be used to run some async actions from outside
@linev linev requested a review from silverweed September 25, 2025 10:39
@linev linev self-assigned this Sep 25, 2025
@linev linev requested a review from bellenot as a code owner September 25, 2025 10:39
@linev linev marked this pull request as draft September 25, 2025 10:39
@silverweed
Copy link
Contributor

silverweed commented Sep 25, 2025

I'm not sure how to translate this for my use case: in rootbrowse.cxx I have this code:

int main() {
   // ... 
 
   auto browser = std::make_unique<TBrowser>();
  
   // For classic graphics: ensure rootbrowse quits when the window is closed
   if (auto imp = browser->GetBrowserImp()) {
      if (auto mainframe = imp->GetMainFrame()) {        
         mainframe->Connect("CloseWindow()", "TApplication", &app, "Terminate()");
      }
   }
  
  // TODO: do the same as the paragraph above but for the web graphics

   std::cout << "Press ctrl+c to exit.\n";
   while (!gROOT->IsInterrupted() && !gSystem->ProcessEvents()) {
      std::this_thread::sleep_for(std::chrono::milliseconds(10));
   }
   return 0;
}

Ideally I don't want to "know" about the internal RBrowser from here, I want to talk to browser or browser->GetBrowserImp().
I want to call TApplication::Terminate() when the ClearOnClose is triggered, but how do I do it from here? (without modifying the TBrowserImp interface further?)

Copy link

Test Results

    21 files      21 suites   3d 15h 41m 53s ⏱️
 3 678 tests  3 677 ✅ 0 💤 1 ❌
75 420 runs  75 414 ✅ 5 💤 1 ❌

For more details on these failures, see this check.

Results for commit 1327f51.

@linev
Copy link
Member Author

linev commented Sep 26, 2025

Ideally I don't want to "know" about the internal RBrowser from here, I want to talk to browser or browser->GetBrowserImp().

That's why I add last commit with changes of RWebBrowserImp class.
It can assign ClearOnClose handle which is destroyed when last connection is closed.
And provide its own handler here.

So PR is incomplete and just shows the direction.
One still need add some handler to base TBrowserImp class and invoke it in correspondent implementation properly.

Also one should be careful - ClearOnClose handle destroyed also during regular ROOT shutdown when instance of RWebBrowserImp can be already deleted.

@silverweed
Copy link
Contributor

To get signal immediately with browser close, one should change gEnv->SetValue("WebGui.ReconnectTmout", -1);

Can't we add a SetReconnectTmout instead of having to pass through TEnv (which does an insane amount of work to Set/Get values compared to what could be in principle done by setting a single class member)?
Also, as far as I understand it's currently impossible to change this timeout after having created the RWebBrowserImp, which is not ideal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants