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();
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;
}
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.