Commit def5b19e authored by Daniel Brown's avatar Daniel Brown
Browse files

further work for freezing components

parent e4409568
Pipeline #1772 failed with stage
in 13 seconds
...@@ -840,7 +840,7 @@ class kat(object): ...@@ -840,7 +840,7 @@ class kat(object):
return object.__new__(cnew) return object.__new__(cnew)
def __init__(self, kat_file=None, kat_code=None, katdir="", katname="", tempdir=None, tempname=None): def __init__(self, kat_file=None, kat_code=None, katdir="", katname="", tempdir=None, tempname=None):
self._unfreeze()
self.__looking = False self.__looking = False
self.scene = None # scene object for GUI self.scene = None # scene object for GUI
self.verbose = True self.verbose = True
...@@ -888,6 +888,17 @@ class kat(object): ...@@ -888,6 +888,17 @@ class kat(object):
if kat_file != None: if kat_file != None:
self.loadKatFile(kat_file) self.loadKatFile(kat_file)
self._freeze()
def _freeze(self): self.__dict__["____FROZEN____"] = True
def _unfreeze(self): self.__dict__["____FROZEN____"] = False
def __setattr__(self, name, value):
if "____FROZEN____" in self.__dict__ and self.__dict__["____FROZEN____"] and not hasattr(self, name):
warnings.warn("'%s' does not have attribute called '%s'" % (self.__name, name), stacklevel=2)
super(kat, self).__setattr__(name, value)
def deepcopy(self): def deepcopy(self):
return copy.deepcopy(self) return copy.deepcopy(self)
...@@ -2033,6 +2044,7 @@ class kat(object): ...@@ -2033,6 +2044,7 @@ class kat(object):
def add(self, obj, block=NO_BLOCK): def add(self, obj, block=NO_BLOCK):
try: try:
self._unfreeze()
obj.tag = block obj.tag = block
self.__blocks[block].contents.append(obj) self.__blocks[block].contents.append(obj)
...@@ -2068,6 +2080,8 @@ class kat(object): ...@@ -2068,6 +2080,8 @@ class kat(object):
except pkex.BasePyKatException as ex: except pkex.BasePyKatException as ex:
pkex.PrintError("Error on adding object:", ex) pkex.PrintError("Error on adding object:", ex)
finally:
self._freeze()
def readOutFile(self, filename): def readOutFile(self, filename):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment