Skip to content

Commit 3dff14f

Browse files
committed
[RF] Don't override TObject::Clone() in TH2Poly
The `TH1` base class already implements the `Clone()` method in such a way that no TH1-derived class needs to re-implement it, also cloning the fit functions correctly. However, there is one TH1-derived class that again overrides `Clone()` with a fallback to `TNamed` methods, which doesn't work for the TH1 family and can lead to crashes.
1 parent 22ab6ae commit 3dff14f

File tree

2 files changed

+0
-14
lines changed

2 files changed

+0
-14
lines changed

hist/hist/inc/TH2Poly.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ class TH2Poly : public TH2 {
8181
Bool_t Add(const TH1 *h1, const TH1 *h2, Double_t c1=1, Double_t c2=1) override;
8282
Bool_t Add(TF1 *h1, Double_t c1=1, Option_t *option="") override;
8383
void ClearBinContents(); // Clears the content of all bins
84-
TObject *Clone(const char* newname = "") const override;
8584
void Copy(TObject & newth2p) const override;
8685
void ChangePartition(Int_t n, Int_t m); // Sets the number of partition cells to another value
8786
using TH2::Multiply;

hist/hist/src/TH2Poly.cxx

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -547,19 +547,6 @@ void TH2Poly::ChangePartition(Int_t n, Int_t m)
547547
}
548548
}
549549

550-
////////////////////////////////////////////////////////////////////////////////
551-
/// Make a complete copy of the underlying object. If 'newname' is set,
552-
/// the copy's name will be set to that name.
553-
554-
TObject* TH2Poly::Clone(const char* newname) const
555-
{
556-
// TH1::Clone relies on ::Copy to implemented by the derived class.
557-
// Until this is implemented, revert to the much slower default version
558-
// (and possibly non-thread safe).
559-
560-
return TNamed::Clone(newname);
561-
}
562-
563550
////////////////////////////////////////////////////////////////////////////////
564551
/// Clears the contents of all bins in the histogram.
565552

0 commit comments

Comments
 (0)