Browse Source

Fix deleting content linked CC blocks

master
Nils 5 years ago
parent
commit
4d6b703940
  1. 7
      engine/api.py
  2. 10
      engine/ccsubtrack.py

7
engine/api.py

@ -145,7 +145,7 @@ class ClientCallbacks(Callbacks): #inherits from the templates api callbacks
for extra block view or background colors."""
track = session.data.trackById(trId)
if cc in track.ccGraphTracks:
graphTracksThatNeedUpdate = track.ccGraphTracks[cc].otherTracksWithOurLinkedContent()
graphTracksThatNeedUpdate = track.ccGraphTracks[cc].otherTracksWithOurLinkedContent()
for gTr in graphTracksThatNeedUpdate:
trId = id(gTr.parentTrack)
@ -515,6 +515,7 @@ def transposeScore(rootPitch, targetPitch):
There is also tranpose. But no transposeTrack, this is just select track and transpose."""
session.data.transposeScore(rootPitch, targetPitch)
session.history.register(lambda r=rootPitch,t=targetPitch: transposeScore(t,r), descriptionString="transpose score")
callbacks._historyChanged()
_updateCallbackAllTracks()
def useCurrentTrackAsMetronome():
@ -1966,9 +1967,10 @@ def deleteCCBlock(graphBlockId):
oldData = ccTrack.serialize()
deletedBlock = ccTrack.deleteBlock(graphBlock)
if deletedBlock: #not the last block
#Blocks are never truly deleted but a stored in the GraphBlock.allBlocks dict. This keeps the reference to this deleted block alive and it can be added through rearrange, which gets its blocks from this dict.
#Blocks are never truly deleted but stored in the GraphBlock.allBlocks dict. This keeps the reference to this deleted block alive and it can be added through rearrange, which gets its blocks from this dict.
description = "Delete CC Block"
session.history.register(lambda: _lazyCCUndoRedo(trId, cc, oldData, description), descriptionString=description)
callbacks._historyChanged()
callbacks._updateGraphTrackCC(trId, cc)
def extendLastCCBlockToTrackLength(trId, cc):
@ -1990,7 +1992,6 @@ def splitCCBlock(graphBlockId, positionInTicksRelativeToBlock):
callbacks._historyChanged()
callbacks._updateGraphTrackCC(trId, cc)
def mergeWithNextGraphBlock(graphBlockId):
trId, cc, graphBlock = session.data.graphBlockById(graphBlockId)
ccTrack = session.data.trackById(trId).ccGraphTracks[cc]

10
engine/ccsubtrack.py

@ -534,7 +534,7 @@ class GraphTrackCC(object):
"""at least one block. If you want to delete the track
use api.deleteGraphTrackCC"""
if len(self.blocks) > 1:
graphBlock.parentGraphTrack = None
#graphBlock.parentGraphTrack = None #We still need this for undo!
self.blocks.remove(graphBlock)
return graphBlock
@ -685,13 +685,13 @@ class GraphTrackCC(object):
if block.getMaxContentPosition() == block.duration:
block.remove(block.duration)
def otherTracksWithOurLinkedContent(self)->set:
"""returns all tracks that need to be updated we change"""
"""returns all tracks that need to be updated"""
#TODO: A bit wasteful. Optimisation? Did really a content linked block change?
result = set()
for block in self.blocks:
for linkedBlock in block.linkedContentBlocks:
for linkedBlock in block.linkedContentBlocks:
result.add(linkedBlock.parentGraphTrack)
assert result #at least this very track
assert result #at least this very track
assert len(result) <= len(self.parentTrack.parentData.tracks) #For now we assume that blocks cannot be linked across CCs. This can be removed after we tested it for a while and the time comes for cross-CC links
return result

Loading…
Cancel
Save