[Groonga-commit] ranguba/chupa-text-decomposer-webkit at 1f2391f [master] Handle snapshot error

Back to archive index

Kouhei Sutou null+****@clear*****
Wed Jul 12 12:34:52 JST 2017


Kouhei Sutou	2017-07-12 12:34:52 +0900 (Wed, 12 Jul 2017)

  New Revision: 1f2391f5d953ce98219a69dd5c1e683d782065e9
  https://github.com/ranguba/chupa-text-decomposer-webkit/commit/1f2391f5d953ce98219a69dd5c1e683d782065e9

  Message:
    Handle snapshot error

  Modified files:
    lib/chupa-text/decomposers/webkit.rb

  Modified: lib/chupa-text/decomposers/webkit.rb (+20 -11)
===================================================================
--- lib/chupa-text/decomposers/webkit.rb    2017-07-12 11:28:18 +0900 (cda92cb)
+++ lib/chupa-text/decomposers/webkit.rb    2017-07-12 12:34:52 +0900 (1e2334e)
@@ -135,17 +135,26 @@ module ChupaText
                                 @screenshot_cancellable) do |_, result|
                 @screenshot_cancellable = nil
                 @main_loop.quit
-                snapshot_surface = view.get_snapshot_finish(result)
-                debug do
-                  size = "#{snapshot_surface.width}x#{snapshot_surface.height}"
-                  "#{log_tag}[screenshot][finish] #{view.uri}: #{size}"
-                end
-                unless snapshot_surface.width.zero?
-                  png = convert_snapshot_surface_to_png(snapshot_surface)
-                  screenshot = Screenshot.new("image/png",
-                                              [png].pack("m*"),
-                                              "base64")
-                  @current_data.screenshot = screenshot if @current_data
+                begin
+                  snapshot_surface = view.get_snapshot_finish(result)
+                rescue
+                  error do
+                    message = "failed to create snapshot: #{view.uri}: "
+                    message << "#{$!.class}: #{$!.message}"
+                    "#{log_tag}[screenshot][failed] #{message}"
+                  end
+                else
+                  debug do
+                    size = "#{snapshot_surface.width}x#{snapshot_surface.height}"
+                    "#{log_tag}[screenshot][finish] #{view.uri}: #{size}"
+                  end
+                  unless snapshot_surface.width.zero?
+                    png = convert_snapshot_surface_to_png(snapshot_surface)
+                    screenshot = Screenshot.new("image/png",
+                                                [png].pack("m*"),
+                                                "base64")
+                    @current_data.screenshot = screenshot if @current_data
+                  end
                 end
               end
             end
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index