Odd TGComboBox effect

Hello,

I’ve built an app that uses a TGComboBox to select a file from a list to load. It works, but while the load file function is running, no mouse clicks are read by the computer anywhere. You can move the mouse pointer around but clicking does nothing. It’s still possible to navigate around with keyboard shortcuts.

Anyone know what causes this and how I might fix it?

Here’s the code for the combo box:

           DataFile=new TGComboBox(FileFrame,-1,kHorizontalFrame | kSunkenFrame | kDoubleBorder | kOwnBackground);
           //TSystemDirectory dir("Datafiles", "/tdata/t1006/CmbTB4TrackFiles/");
           TSystemDirectory dir("Datafiles", "/media/Data/PhysicsResearch/MTestTracking/");
           TList *files=dir.GetListOfFiles();
           files->Sort();
           TIter next(files);
           TSystemFile *file;
           UInt_t n=0;
           while((file=(TSystemFile*) next()))
           {
               if(TString(file->GetName()).EndsWith(".root"))
               {
                   DataFile->AddEntry(file->GetName(),n);
                   ++n;
               }
           }
           FileFrame->AddFrame(DataFile, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2));
           DataFile->MoveResize(16,16,200,22);
           DataFile->Connect("Selected(Int_t)","Scope",this,"LoadFile()");

Here’s the load file function. Beyond loading the data file, it also clears data used from the previous file and performs some calculations. Incrementing the status bar, FileLBar, is rarely visible until the function is complete. Maybe the problem is related?

void Scope::LoadFile()
{
    if(DataLoaded==true){
        delete Ch0hist;
        delete Ch1hist;
        delete Ch2hist;
        delete Ch3hist;

        delete Ch0NoCut;
        delete Ch1NoCut;
        delete Ch2NoCut;
        delete Ch3NoCut;

        delete Ch0INoCut;
        delete Ch1INoCut;
        delete Ch2INoCut;
        delete Ch3INoCut;
        
        lfile->Close();
        FileLBar->Reset();
        delete CurrentEvent;
        CurrentEvent=new TB4Event();

        Ch0hist   = new TH1F("Ch4","ADC counts from Ch4",2100,-1000,20000);
        Ch1hist   = new TH1F("Ch5","ADC counts from Ch5",2100,-1000,20000);
        Ch2hist   = new TH1F("Ch8","ADC counts from Ch8",2100,-1000,20000);
        Ch3hist   = new TH1F("Ch9","ADC counts from Ch9",2100,-1000,20000);

        Ch0NoCut =new TH1F("Ch4NoCut","ADC counts from Ch4",525,-100,2000);
        Ch1NoCut =new TH1F("Ch5NoCut","ADC counts from Ch5",525,-100,2000);
        Ch2NoCut =new TH1F("Ch8NoCut","ADC counts from Ch8",525,-100,2000);
        Ch3NoCut =new TH1F("Ch9NoCut","ADC counts from Ch9",525,-100,2000);

        Ch0INoCut=new TH1F("Ch4INoCut","ADC counts from Ch4",2100,-1000,20000);
        Ch1INoCut=new TH1F("Ch5INoCut","ADC counts from Ch5",2100,-1000,20000);
        Ch2INoCut=new TH1F("Ch8INoCut","ADC counts from Ch8",2100,-1000,20000);
        Ch3INoCut=new TH1F("Ch9INoCut","ADC counts from Ch9",2100,-1000,20000);
    }
    //TString loadpath="/tdata/t1006/CmbTB4TrackFiles/";
    TString loadpath="/media/Data/PhysicsResearch/MTestTracking/";
    TString Lfile=DataFile->GetSelectedEntry()->GetTitle();
    TString filepath=loadpath+Lfile;
    lfile=TFile::Open(filepath);
    CosmicData=(TTree*) lfile->Get("RunData");
    CosmicData->SetBranchAddress("TB4Event",&CurrentEvent);
    nentry = CosmicData->GetEntries();
    eventsize=CurrentEvent->GetEvtLength()-5;
    PeakMark=0;

    if(DataLoaded!=true){
        delete sizer;
        sizer=new TH2F("GraphHolder","traces",eventsize+1,0,eventsize,500,2000,8500);
        sizer->SetMarkerColor(0);
        sizer->GetXaxis()->SetTitle("Tics");
        sizer->GetYaxis()->SetTitle("ADC counts");
    }

    DataLoaded=true;
    FileLBar->Increment(.4);

    SigIntSig();
    FileLBar->Increment(.2);
    EventMark();//(0,0,"off");
    event=events.begin();
    //DrawTraces();

    ticker=0;
    Integralhist();
    FileLBar->Increment(.2);
    Amplitudehist();
    ticker=1;

    binhighlight=true;
    Lfile+="\nloaded.";
    FileLBar->Increment(.2);
    EvtNumPos->SetText(Lfile);

}

Thanks,
Stephen

Hi Stephen,

It is hard to tell from the code you provide, but it seems normal that during time consuming methods (e.g. in for/while loops), the event handling not handled. To solve this issue, gSystem->ProcessEvents() should be added somewhere in these loops (if possible at all) in order to handle (e.g. GUI) events.
If this is not what you observe, or if I misunderstood the issue, feel free to provide a running macro reproducing the problem.

Cheers, Bertrand.

Hello Bertrand,

gSystem->ProcessEvents() worked. Thanks! Simple answers are always the best.

Stephen