Skip to content

Commit

Permalink
[visualize] User-friendly error message for widthless/heightless layers
Browse files Browse the repository at this point in the history
  • Loading branch information
jbinney committed Nov 1, 2015
1 parent 589c527 commit 4aa9cdf
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion commands/FBVisualizationCommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,15 @@ def _showColor(color):

def _showLayer(layer):
layer = '(' + layer + ')'
size = '((CGRect)[(id)' + layer + ' bounds]).size'

lldb.debugger.HandleCommand('expr (void)UIGraphicsBeginImageContextWithOptions(((CGRect)[(id)' + layer + ' bounds]).size, NO, 0.0)')
width = float(fb.evaluateExpression(size + '.width'))
height = float(fb.evaluateExpression(size + '.height'))
if width == 0.0 or height == 0.0:
print 'Nothing to see here - the size of this element is {} x {}.'.format(width, height)
return

lldb.debugger.HandleCommand('expr (void)UIGraphicsBeginImageContextWithOptions(' + size + ', NO, 0.0)')
lldb.debugger.HandleCommand('expr (void)[(id)' + layer + ' renderInContext:(void *)UIGraphicsGetCurrentContext()]')

frame = lldb.debugger.GetSelectedTarget().GetProcess().GetSelectedThread().GetSelectedFrame()
Expand Down

0 comments on commit 4aa9cdf

Please sign in to comment.