On MacOS, I encountered a warning about QuartzWindow ordered front from a non-active application

When I was running a compiler for an executable program, I encountered this error:

**2023-03-29 12:55:50.408795+0200 OTEffThreshReader[24910:250037] [Window] Warning: Window QuartzWindow 0x11b429600 ordered front from a non-active application and may order beneath the active application's windows.**

**2023-03-29 12:55:50.529725+0200 OTEffThreshReader[24910:250037] [default] CGSWindowShmemCreateWithPort failed on port 0**

I guess the reason for it was that I created Canvas and didn’t activate my application correctly.
What should I do to activate my application?

This is the code snippet I tested:

    TApplication* myApp = new TApplication("myApp", &argc, argv);
    TCanvas* thresholds_distr = new TCanvas("c1","c1",950,10,600,400);
    TH1D* h_thrs__1 = new TH1D("h1", "h1", 50, 0, 50);
    h_thrs__1->Fill(100);
    thresholds_distr->cd();
    h_thrs__1->Draw();
    thresholds_distr->Modified();
    thresholds_distr->Update();
    myApp->Run();

ROOT Version: ROOT Version: 6.26/06
Platform: MacOS 13.3(22E252)
Compiler: Not Provided


Welcome to the ROOT forum.

What about:

File thresholds.C

void thresholds.C() {
    TCanvas* thresholds_distr = new TCanvas("c1","c1",950,10,600,400);
    TH1D* h_thrs__1 = new TH1D("h1", "h1", 50, 0, 50);
    h_thrs__1->Fill(100);
    thresholds_distr->cd();
    h_thrs__1->Draw();
}
$ root thresholds.C

does it work ?

Yes, it works well. I have tried not to use the TApplication, and it will not have a warning. It warns just because of the TApplication.

You need the TApplication only in a standalone application (i.e., in your own “main”).

Yes. I do. I also tested it on other OS (Linux), and only macOS will cause this warning.

Something for @Axel and/or @couet then.

@destiny_712 Can you provide a minimal “main” which reproduces your problem (and how exactly you build your application)?

1 Like

main.cpp (642 位元組)
In fact, I am using Xcode to compile my program. I do not know the specific compilation settings. I chose the default option of Xcode.

//
//  main.cpp
//  TestCanvas
//
//  Created by destiny_712 on 2023/4/4.
//

#include <iostream>

#include <TApplication.h>
#include <TCanvas.h>
#include <TH1D.h>

int main(int argc, const char * argv[])
{
    // insert code here...
    TApplication* myApp = new TApplication("myApp", 0, 0);
    TCanvas* thresholds_distr = new TCanvas("c1","c1",950,10,600,400);
    TH1D* h_thrs__1 = new TH1D("h1", "h1", 50, 0, 50);
    h_thrs__1->Fill(100);
    thresholds_distr->cd();
    h_thrs__1->Draw();
    thresholds_distr->Modified();
    thresholds_distr->Update();
    myApp->Run();
    std::cout << "Hello, world!" << std::endl;
    return 0;
}

Actually, it’s not really clear to me what you exactly do when you get these errors (what is a “non-active application”?).

Try:
$(root-config --cxx --cflags) -O2 -Wall -Wextra -o main main.cpp $(root-config --libs) ; ./main

Thank you for your solution. Doing this does remove the warnings I was encountering earlier.
But it lacks the convenience of using Run directly from Xcode to automate.
Thank you anyway. At least it is not ROOT’s problem.

So, we need someone who works with Xcode to try to “explain” it.

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