Fatal error: requested drawable 0 is not found among currently valid drawables

Dear experts

I found that if I write the instantiation of TApplication after TCanvas I will get this error, like:

        TCanvas* c = new TCanvas();
        TH1D* h = new TH1D("mom", "mom", 100, 0, 10);
//Do Something
        TApplication app("app", &argc, argv);
        h->Draw();
        app.Run();

But if I instantiate the TApplication at first I won’t get this error, why this happens?

Yes, TApplication first is the way to proceed, as explained here:

Is there a way that don’t pass the arguments to TApplication, like to pass NULL pointers? The reason I don’t want to put it at first is it will bring arguments away…

From the documentation here:

The recognized options are removed from the argument array. The original list of argument options can be retrieved via the Argc() and Argv() methods.

I would say that it makes sense to pass them to TApplication (so you can pass options to it), and name your options such that they don’t clash with the ones of TApplication.

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