GNOME Bugzilla – Bug 701264
Disable search for file types that don't implement EvDocumentFind
Last modified: 2013-05-31 11:30:21 UTC
XPS is an example (see attachment) of a file type that does not implement EvDocumentFind. Try opening an XPS file in gnome-documents and start searching inside in the preview. It will crash after a while. The search functionaility is disabled in evince for such documents. See ev_window_setup_action_sensitivity in shell/ev-window.c for details.
My XPS is too big to be attached. So here it is: http://rishi.fedorapeople.org/crash.xps
Created attachment 245642 [details] [review] preview: Disable search if EvDocumentFind is not implemented Is there a better way to detect if an interface is implemented from GJS?
Review of attachment 245642 [details] [review]: Looks good, with a minor comment below. Feel free to correct that and push to master. ::: src/preview.js @@ +874,3 @@ + evDoc.find_text(); + } catch (e if e instanceof TypeError) { + try { I would just set isFind = false for all the possible exceptions here - I don't think we have a more elegant way to do this unfortunately.
(In reply to comment #3) > Review of attachment 245642 [details] [review]: > > Looks good, with a minor comment below. Feel free to correct that and push to > master. > > ::: src/preview.js > @@ +874,3 @@ > + evDoc.find_text(); > + } catch (e if e instanceof TypeError) { > + try { > > I would just set isFind = false for all the possible exceptions here - I don't > think we have a more elegant way to do this unfortunately. The reason I separated out TypeError from other exceptions is that "evDoc.find_text()" will generate an exception even if EvDocumentFind is implemented because the method does not work with a "void" argument list. So a TypeError denotes that the method does not exist because the interface was not implemented. Ofcourse I can construct a valid list of arguments, but I decided not to bother since we don't want to actually find anything.
Fair enough; let's get this in as is then. Thanks!