-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PyROOT] Retain C++ ownership for TColor
- Loading branch information
1 parent
bfa0b18
commit 9e2df7e
Showing
3 changed files
with
32 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
bindings/pyroot/pythonizations/python/ROOT/_pythonization/_tcolor.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Author: Vincenzo Eduardo Padulano CERN 11/2024 | ||
|
||
################################################################################ | ||
# Copyright (C) 1995-2024, Rene Brun and Fons Rademakers. # | ||
# All rights reserved. # | ||
# # | ||
# For the licensing terms see $ROOTSYS/LICENSE. # | ||
# For the list of contributors see $ROOTSYS/README/CREDITS. # | ||
################################################################################ | ||
from . import pythonization | ||
|
||
def _TColor_constructor(self, *args, **kwargs): | ||
""" | ||
Forward the arguments to the C++ constructor and retain ownership. This | ||
helps avoiding double deletes due to ROOT automatic memory management. | ||
""" | ||
self._cpp_constructor(*args, **kwargs) | ||
import ROOT | ||
ROOT.SetOwnership(self, False) | ||
|
||
|
||
@pythonization("TColor") | ||
def pythonize_tcolor(klass): | ||
klass._cpp_constructor = klass.__init__ | ||
klass.__init__ = _TColor_constructor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters