#include using namespace std; /* I receive on a regular basis an histo that I must display in the Canvas. My problem is that users start to interact with the canvas and the histo and when the update occur and I replace the displayed histo, crashes occur because the action of the user spanned over the update. This example shows the phenomenon : it draws an histogram, wait 5 seconds to let the user have time to open the contextual menu of the histo, then update the histo and if the user click on the contextual menu after the update, it crashes. How to handle this situation ? Do I have a way of knowing that the user is interacting with the canvas or its content ? Any other idea ? */ void testContext3() { // create the canvas TCanvas *c1 = new TCanvas(); c1->Show(); c1->cd(); // Prepare the th1 TH1F *h1 = new TH1F("1", "1", 100, 0, 100); h1->Fill(10); h1->Draw(); c1->Update(); // wait 5 seconds, take the opportunity of clicking on "inspect" // in the contextual menu previously opened. for (size_t ii = 0; ii < 1000; ++ii) { gSystem->ProcessEvents(); gSystem->Sleep(5); } // Prepare the replacement th1 TH1F *h = new TH1F("2", "2", 100, 0, 100); h->Fill(20); // replace the histo by a new one and display it in the canvas *h1 = *h; // this works one time //h1->Reset(); // this doesn't workd //h1->Add(h); //c1->Clear(); h1->Draw(); c1->Update(); // wait 5 seconds, take the opportunity of clicking on "inspect" // in the contextual menu previously opened. for (size_t ii = 0; ii < 1000; ++ii) { gSystem->ProcessEvents(); gSystem->Sleep(5); } }