Skip to content

Commit

Permalink
Reduce using resource
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Jul 11, 2017
1 parent 84927cb commit dd46858
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/chupa-text/decomposers/webkit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ def decompose(data)
def create_screenshot(data)
screenshot = nil

view_context = WebKit2Gtk::WebContext.new(ephemeral: true)
view = WebKit2Gtk::WebView.new(context: view_context)
@@view_context ||= WebKit2Gtk::WebContext.new(ephemeral: true)
view = WebKit2Gtk::WebView.new(context: @@view_context)
window = Gtk::OffscreenWindow.new
window.set_default_size(800, 600)
window.add(view)
Expand Down Expand Up @@ -104,6 +104,7 @@ def create_screenshot(data)
until finished
main_context.iteration(true)
end
window.destroy

screenshot
end
Expand Down

0 comments on commit dd46858

Please sign in to comment.