Skip to content

Commit

Permalink
Ensure that the color_space and dash attributes are properly copied w…
Browse files Browse the repository at this point in the history
…hen using dup/clone to copy a graphic state
  • Loading branch information
dmarkow committed Jan 14, 2014
1 parent 18ec12b commit 77ffca0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/pdf/core/graphics_state.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ def dash_setting
"[#{@dash[:dash]} #{@dash[:space]}] #{@dash[:phase]} d"
end
end

private

def initialize_copy(other)
@color_space = other.color_space.dup
@dash = other.dash.dup
end
end
end
end
6 changes: 6 additions & 0 deletions spec/graphics_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,12 @@
new_state.color_space.object_id.should_not == @pdf.graphic_state.color_space.object_id
new_state.dash.object_id.should_not == @pdf.graphic_state.dash.object_id
end

it "should dup the color_space and dash hashes when duping" do
new_state = @pdf.graphic_state.dup
new_state.color_space.object_id.should_not == @pdf.graphic_state.color_space.object_id
new_state.dash.object_id.should_not == @pdf.graphic_state.dash.object_id
end
end

describe "When using transformation matrix" do
Expand Down

0 comments on commit 77ffca0

Please sign in to comment.