Ratio plot axis titles root 6.38

This code:

TRatioPlot* rp = new TRatioPlot(hData,hStack);
rp->Draw();
rp->GetUpperPad()->cd();

((THStack*)rp->GetUpperRefObject())->GetXaxis()->SetTitle(hData->GetXaxis()->GetTitle());
((THStack*)rp->GetUpperRefObject())->GetYaxis()->SetTitle(hData->GetYaxis()->GetTitle());

worked fine in root 6.36 but fails at runtime in root 6.38, giving a bus error when I try to do GetXaxis(). Can anyone tell me the correct way to set axis titles of a ratio plot in 6.38?

@Danilo Looks like an incompatible change in ROOT.
The GetUpperRefObject (correctly) returns hData in ROOT 6.38 and (incorrectly) hStack in ROOT 6.36 (and ROOT 6.34).

@bethlong06 Try with (it should work with any ROOT version):
TRatioPlot *rp = new TRatioPlot(hStack, hData);

In fact TRatioPlot *rp = new TRatioPlot(hStack,hData); solves the problem