-
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++ memory ownership for TStyle
- Loading branch information
1 parent
1de46e8
commit 283164f
Showing
3 changed files
with
43 additions
and
4 deletions.
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
29 changes: 29 additions & 0 deletions
29
bindings/pyroot/pythonizations/python/ROOT/_pythonization/_tstyle.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,29 @@ | ||
# Author: Jonas Rembser 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 _TStyle_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("TStyle") | ||
def pythonize_tstyle(klass): | ||
|
||
klass._cpp_constructor = klass.__init__ | ||
klass.__init__ = _TStyle_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