Revert "use weakrefs to break reference cycles between a world and its dimensions, and a world and its chunks."
Weakrefs are the wrong solution, we need to remove the __del__ from MCInfdevOldLevel This reverts commit 12a5982b1693def30d74f9e656d87984e50fd8b1.
This commit is contained in:
parent
768d88ca33
commit
3d1d76d04b
@ -13,7 +13,6 @@ import subprocess
|
|||||||
import sys
|
import sys
|
||||||
import urllib
|
import urllib
|
||||||
import tempfile
|
import tempfile
|
||||||
import weakref
|
|
||||||
from os.path import join, dirname, basename
|
from os.path import join, dirname, basename
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
warn, error, info, debug = log.warn, log.error, log.info, log.debug
|
warn, error, info, debug = log.warn, log.error, log.info, log.debug
|
||||||
@ -637,16 +636,7 @@ class InfdevChunk(EntityLevel):
|
|||||||
else:
|
else:
|
||||||
if not world.containsChunk(*chunkPosition):
|
if not world.containsChunk(*chunkPosition):
|
||||||
raise ChunkNotPresent("Chunk {0} not found", self.chunkPosition)
|
raise ChunkNotPresent("Chunk {0} not found", self.chunkPosition)
|
||||||
|
|
||||||
_world = None
|
|
||||||
@property
|
|
||||||
def world(self):
|
|
||||||
if self._world:
|
|
||||||
return self._world()
|
|
||||||
@world.setter
|
|
||||||
def world(self, val):
|
|
||||||
self._world = weakref.ref(val)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def materials(self):
|
def materials(self):
|
||||||
return self.world.materials
|
return self.world.materials
|
||||||
@ -2241,8 +2231,6 @@ class MCInfdevOldLevel(ChunkedLevelMixin, EntityLevel):
|
|||||||
return self.bounds.size
|
return self.bounds.size
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
""" Immediately closes any filehandles opened by the world, discards all
|
|
||||||
changes and unloads all chunks and region files. """
|
|
||||||
for rf in (self.regionFiles or {}).values():
|
for rf in (self.regionFiles or {}).values():
|
||||||
rf.close();
|
rf.close();
|
||||||
|
|
||||||
@ -3059,7 +3047,7 @@ class MCInfdevOldLevel(ChunkedLevelMixin, EntityLevel):
|
|||||||
class MCAlphaDimension (MCInfdevOldLevel):
|
class MCAlphaDimension (MCInfdevOldLevel):
|
||||||
def __init__(self, parentWorld, dimNo, create=False):
|
def __init__(self, parentWorld, dimNo, create=False):
|
||||||
filename = os.path.join(parentWorld.worldDir, "DIM" + str(int(dimNo)))
|
filename = os.path.join(parentWorld.worldDir, "DIM" + str(int(dimNo)))
|
||||||
self._parentWorld = weakref.ref(parentWorld);
|
self.parentWorld = parentWorld;
|
||||||
MCInfdevOldLevel.__init__(self, filename, create)
|
MCInfdevOldLevel.__init__(self, filename, create)
|
||||||
self.dimNo = dimNo
|
self.dimNo = dimNo
|
||||||
self.filename = parentWorld.filename
|
self.filename = parentWorld.filename
|
||||||
@ -3067,13 +3055,6 @@ class MCAlphaDimension (MCInfdevOldLevel):
|
|||||||
self.players = parentWorld.players
|
self.players = parentWorld.players
|
||||||
self.playerTagCache = parentWorld.playerTagCache
|
self.playerTagCache = parentWorld.playerTagCache
|
||||||
|
|
||||||
_parentWorld = None
|
|
||||||
@property
|
|
||||||
def parentWorld(self):
|
|
||||||
if self._parentWorld:
|
|
||||||
return self._parentWorld()
|
|
||||||
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def root_tag(self): return self.parentWorld.root_tag;
|
def root_tag(self): return self.parentWorld.root_tag;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user