From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?utf-8?Q?No=C3=A9_Lopez?= via "Emacs development discussions." Newsgroups: gmane.emacs.devel Subject: Calling interactive lisp functions from C Date: Sun, 22 Sep 2024 18:38:53 +0200 Message-ID: <23628.1661827647$1727026648@news.gmane.org> Reply-To: =?utf-8?Q?No=C3=A9_Lopez?= Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23739"; mail-complaints-to="usenet@ciao.gmane.io" To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Sep 22 19:37:20 2024 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ssQWO-00061a-GC for ged-emacs-devel@m.gmane-mx.org; Sun, 22 Sep 2024 19:37:20 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ssQVk-0003cN-Cv; Sun, 22 Sep 2024 13:36:40 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ssPc7-00069S-6q for emacs-devel@gnu.org; Sun, 22 Sep 2024 12:39:12 -0400 Original-Received: from smtp.domeneshop.no ([2a01:5b40:0:3006::1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ssPc1-0002ok-AT for emacs-devel@gnu.org; Sun, 22 Sep 2024 12:39:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xn--no-cja.eu; s=ds202402; h=Content-Transfer-Encoding:Content-Type: MIME-Version:Message-ID:Date:Subject:To:From:From:Sender:Reply-To:Subject: Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=JxhJgjIaA0VFwvDjLaYLBYJPAhsh0y12g1us4yRvfz0=; b=1luI9XhSLklm09MTs+fdhgEE7d vCcyIwZklICWK85VOTvPs0heQmTkM8loF+5sh4RtU8VGzqgL9XIrOf+oyQRATfJ4NpFAV1BRoZSbv LQiEbrP9DZqWbifZ1MLMyzau9tlTqtD0NPVF5khGTtj+JCnH+EAwkVFe+NUFxj6Ns9422yl89dfeA G7mN1MsiDVm6hjl2Ke2Dxs1Cox0x9fdRRD+YrXMKumRHFnMMqCuvBTxoEkCf7sTmujHrwaogacU1o B1Z2lhRfigTB9E6QBQzg1Di11Xbglhr1AmKQRpc442TdBtlsPPovI7qV/RTg/hDTr80yiCGNij Original-Received: from [2a01:e0a:990:a960:b62e:99ff:fe08:7e05] (port=48928 helo=navi) by smtp.domeneshop.no with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1ssPbr-001Xli-M7 for emacs-devel@gnu.org; Sun, 22 Sep 2024 18:38:55 +0200 Received-SPF: pass client-ip=2a01:5b40:0:3006::1; envelope-from=noe@xn--no-cja.eu; helo=smtp.domeneshop.no X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, INVALID_MSGID=0.568, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Sun, 22 Sep 2024 13:36:38 -0400 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:323931 Archived-At: Hi, I am trying to call the read-file-name function from a C WebKit callback, in this case it is the =C2=AB=E2=80=AFrun-file-chooser=E2=80=AF= =C2=BB signal. I came up with this code which works when selecting a file, but aborts emacs when hitting the =C2=AB=E2=80=AFcancel=E2=80=AF=C2=BB button of the f= ile chooser dialog. static gboolean wpe_run_file_chooser_cb (WebKitWebView *webview, WebKitFileChooserRequest *request, struct xwidget *xw) { /* use read-file-name if only one file is needed, useful for keyboard only usage. */ if (!webkit_file_chooser_request_get_select_multiple (request)) { /* TODO: we can use webkit_file_chooser_request_get_selected_files * to find a default file name for the prompt. */ Lisp_Object file =3D call4 (Qread_file_name, build_string ("Select file"), Qnil, Qnil, Qt); if (EQ (file, Qnil)) { webkit_file_chooser_request_cancel (request); g_message ("canceled file request"); } const char *const selected_files[] =3D { SSDATA (file), NULL }; webkit_file_chooser_request_select_files (request, selected_files); return TRUE; } return TRUE; } The callback is activated from a click action in the WebKit buffer, so =C2=AB=E2=80=AFwaiting_for_input=E2=80=AF=C2=BB is true, causing signal_or_= quit to abort. Using clear_waiting_for_input changes it to a segmentation fault. What can I do to catch the quit signal? Ideally I need to call a function to notify WebKit of the cancelation, or it will hang. Thanks in advance for any help, No=C3=A9 Lopez Backtrace: #0 0x00007fffed094c5c in __pthread_kill_implementation () at /lib64/libc.s= o.6 #1 0x00007fffed0411c6 in raise () at /lib64/libc.so.6 #2 0x00000000004796b8 in terminate_due_to_signal (sig=3Dsig@entry=3D6, bac= ktrace_limit=3Dbacktrace_limit@entry=3D40) at emacs.c:470 #3 0x000000000047b44c in emacs_abort () at sysdep.c:2391 #4 0x0000000000483ac5 in signal_or_quit (error_symbol=3Derror_symbol@entry=3D0xf8d0, data=3Ddata@entry=3D0x0, c= ontinuable=3Dcontinuable@entry=3Dtrue) at eval.c:1858 #5 0x0000000000689ee5 in quit () at eval.c:1830 #6 0x00000000005bfa4a in Fx_file_dialog (prompt=3D, dir=3D, default_filename=3D0x= 0, mustmatch=3D0x30, only_dir_p=3D0x0) at xfns.c:9658 #7 0x00000000006dc917 in exec_byte_code (fun=3D0x7bdc, args_template=3D317= 08, nargs=3D5, args=3D0x7fffe7e00130) at /home/noe/src/emacs/src/lisp.h:2243 #8 0x000000000068c928 in Ffuncall (nargs=3Dnargs@entry=3D5, args=3Dargs@en= try=3D0x7fffffffb960) at eval.c:3093 #9 0x0000000000721e87 in wpe_run_file_chooser_cb (webview=3D, xw=3D, request=3D0x1dbc770) at xwidget-wpe.c:636 #10 wpe_run_file_chooser_cb (webview=3D, request=3D0x1dbc770= , xw=3D) at xwidget-wpe.c:617 #11 0x00007fffecd2b972 in ??? () at /lib64/libffi.so.8 #12 0x00007fffecd282df in ??? () at /lib64/libffi.so.8 #13 0x00007fffecd2af36 in ffi_call () at /lib64/libffi.so.8 #14 0x00007ffff6f7e1f2 in g_cclosure_marshal_generic () at /lib64/libgobjec= t-2.0.so.0 #15 0x00007ffff6f7d7b8 in g_closure_invoke () at /lib64/libgobject-2.0.so.0 #16 0x00007ffff6f92333 in ??? () at /lib64/libgobject-2.0.so.0 #17 0x00007ffff6f93629 in ??? () at /lib64/libgobject-2.0.so.0 #18 0x00007ffff6f99a92 in g_signal_emit_valist () at /lib64/libgobject-2.0.= so.0 #19 0x00007ffff6f99b3f in g_signal_emit () at /lib64/libgobject-2.0.so.0 #20 0x00007ffff0bc7a39 in webkitWebViewRunFileChooserRequest () at /usr/src/debug/wpewebkit-2.44.2/Source/WebKit/UIProcess/API/glib/Web= KitWebView.cpp:2855 #21 0x00007ffff0bb3243 in UIClient::runOpenPanel () at /usr/src/debug/wpewebkit-2.44.2/Source/WebKit/UIProcess/API/glib/Web= KitUIClient.cpp:277 #22 0x00007ffff0abe393 in WebKit::WebPageProxy::runOpenPanel () at /usr/src/debug/wpewebkit-2.44.2/Source/WebKit/UIProcess/WebPageProxy= .cpp:7709 #23 0x00007ffff0635a64 in IPC::callMemberFunction >, WebKit::FrameInfoData&&, WebCore::FileChooserSettings const&), std:= :tuple >, WebKit::Fr= ameInfoData, WebCore::FileChooserSettings> >(WebKit::WebPageProxy*, void (W= ebKit::WebPageProxy::*)(WebCore::ProcessQualified >, WebKit::FrameInfoData&&, WebCore::FileChooserSettings const&), std::= tuple >, WebKit::Fra= meInfoData, WebCore::FileChooserSettings>&&)::{lambda((auto:1&&)...)#1}::op= erator() >, WebKit::= FrameInfoData, WebCore::FileChooserSettings>(WebCore::ProcessQualified >&&, WebKit::FrameInfoData&&, WebCore::FileChooser= Settings&&) const () at /usr/src/debug/wpewebkit-2.44.2/Source/WebKit/Platform/IPC/HandleMes= sage.h:136 #24 std::__invoke_impl >, WebKit::FrameInfoData&&, WebCore::FileChooserSettings const&), s= td::tuple >, WebKit:= :FrameInfoData, WebCore::FileChooserSettings> >(WebKit::WebPageProxy*, void= (WebKit::WebPageProxy::*)(WebCore::ProcessQualified for mor= e, q to quit, c to continue without paging--c F::ObjectIdentifierGeneric >, WebKit::FrameInfoData&&, WebCore::FileChooser= Settings const&), std::tuple >, WebKit::FrameInfoData, WebCore::FileChooserSettings>&&)::{lambd= a((auto:1&&)...)#1}, WebCore::ProcessQualified= >, WebKit::FrameInfoData, WebCore::FileChooserSettings>(std::__invoke_othe= r, IPC::callMemberFunction >, WebKit::FrameIn= foData&&, WebCore::FileChooserSettings const&), std::tuple >, WebKit::FrameInfoData, WebCore::F= ileChooserSettings> >(WebKit::WebPageProxy*, void (WebKit::WebPageProxy::*)= (WebCore::ProcessQualified >, WebKit::FrameInf= oData&&, WebCore::FileChooserSettings const&), std::tuple >, WebKit::FrameInfoData, WebCore::Fi= leChooserSettings>&&)::{lambda((auto:1&&)...)#1}&&, WebCore::ProcessQualifi= ed >&&, WebKit::FrameInfoData&&, WebCore::File= ChooserSettings&&) () at /usr/include/c++/14/bits/invoke.h:61 #25 std::__invoke >, = WebKit::FrameInfoData&&, WebCore::FileChooserSettings const&), std::tuple >, WebKit::FrameInfoD= ata, WebCore::FileChooserSettings> >(WebKit::WebPageProxy*, void (WebKit::W= ebPageProxy::*)(WebCore::ProcessQualified >, W= ebKit::FrameInfoData&&, WebCore::FileChooserSettings const&), std::tuple >, WebKit::FrameInfoDa= ta, WebCore::FileChooserSettings>&&)::{lambda((auto:1&&)...)#1}, WebCore::P= rocessQualified >, WebKit::FrameInfoData, WebC= ore::FileChooserSettings>(IPC::callMemberFunction >, WebKit::FrameInfoData&&, WebCore::FileChooserSettings const&), std:= :tuple >, WebKit::Fr= ameInfoData, WebCore::FileChooserSettings> >(WebKit::WebPageProxy*, void (W= ebKit::WebPageProxy::*)(WebCore::ProcessQualified >, WebKit::FrameInfoData&&, WebCore::FileChooserSettings const&), std::= tuple >, WebKit::Fra= meInfoData, WebCore::FileChooserSettings>&&)::{lambda((auto:1&&)...)#1}&&, = WebCore::ProcessQualified >&&, WebKit::FrameIn= foData&&, WebCore::FileChooserSettings&&) () at /usr/include/c++/14/bits/invoke.h:96 #26 std::__apply_impl= >, WebKit::FrameInfoData&&, WebCore::FileChooserSettings const&), std::tup= le >, WebKit::FrameI= nfoData, WebCore::FileChooserSettings> >(WebKit::WebPageProxy*, void (WebKi= t::WebPageProxy::*)(WebCore::ProcessQualified = >, WebKit::FrameInfoData&&, WebCore::FileChooserSettings const&), std::tupl= e >, WebKit::FrameIn= foData, WebCore::FileChooserSettings>&&)::{lambda((auto:1&&)...)#1}, std::t= uple >, WebKit::Fram= eInfoData, WebCore::FileChooserSettings>, 0ul, 1ul, 2ul>(IPC::callMemberFun= ction >, WebKit::FrameInfoData&&, WebCore::Fi= leChooserSettings const&), std::tuple >, WebKit::FrameInfoData, WebCore::FileChooserSettings> >= (WebKit::WebPageProxy*, void (WebKit::WebPageProxy::*)(WebCore::ProcessQual= ified >, WebKit::FrameInfoData&&, WebCore::Fil= eChooserSettings const&), std::tuple >, WebKit::FrameInfoData, WebCore::FileChooserSettings>&&)= ::{lambda((auto:1&&)...)#1}&&, std::tuple >, WebKit::FrameInfoData, WebCore::FileChooserSetting= s>&&, std::integer_sequence) () at /usr/inclu= de/c++/14/tuple:2921 #27 std::apply >, Web= Kit::FrameInfoData&&, WebCore::FileChooserSettings const&), std::tuple >, WebKit::FrameInfoData= , WebCore::FileChooserSettings> >(WebKit::WebPageProxy*, void (WebKit::WebP= ageProxy::*)(WebCore::ProcessQualified >, WebK= it::FrameInfoData&&, WebCore::FileChooserSettings const&), std::tuple >, WebKit::FrameInfoData,= WebCore::FileChooserSettings>&&)::{lambda((auto:1&&)...)#1}, std::tuple >, WebKit::FrameInfoDa= ta, WebCore::FileChooserSettings> >(IPC::callMemberFunction >, WebKit::FrameInfoData&&, WebCore::FileChooserSettings con= st&), std::tuple >, = WebKit::FrameInfoData, WebCore::FileChooserSettings> >(WebKit::WebPageProxy= *, void (WebKit::WebPageProxy::*)(WebCore::ProcessQualified >, WebKit::FrameInfoData&&, WebCore::FileChooserSettings cons= t&), std::tuple >, W= ebKit::FrameInfoData, WebCore::FileChooserSettings>&&)::{lambda((auto:1&&).= ..)#1}&&, std::tuple= >, WebKit::FrameInfoData, WebCore::FileChooserSettings>&&) () at /usr/include/c++/14/tuple:2936 #28 IPC::callMemberFunction >, WebKit::FrameI= nfoData&&, WebCore::FileChooserSettings const&), std::tuple >, WebKit::FrameInfoData, WebCore::= FileChooserSettings> >(WebKit::WebPageProxy*, void (WebKit::WebPageProxy::*= )(WebCore::ProcessQualified >, WebKit::FrameIn= foData&&, WebCore::FileChooserSettings const&), std::tuple >, WebKit::FrameInfoData, WebCore::F= ileChooserSettings>&&) () at /usr/src/debug/wpewebkit-2.44.2/Source/WebKit/Platform/IPC/HandleMes= sage.h:134 #29 IPC::handleMessage >, WebKit::FrameInfoData&&, WebCore::FileChooserSettings co= nst&)>(IPC::Connection&, IPC::Decoder&, WebKit::WebPageProxy*, void (WebKit= ::WebPageProxy::*)(WebCore::ProcessQualified >= , WebKit::FrameInfoData&&, WebCore::FileChooserSettings const&)) () at /usr= /src/debug/wpewebkit-2.44.2/Source/WebKit/Platform/IPC/HandleMessage.h:236 #30 0x00007ffff063fbdb in WebKit::WebPageProxy::didReceiveMessage () at /usr/src/debug/wpewebkit-2.44.2/build/DerivedSources/WebKit/WebPageP= roxyMessageReceiver.cpp:339 #31 0x00007ffff09c402d in IPC::MessageReceiverMap::dispatchMessage () at /usr/src/debug/wpewebkit-2.44.2/Source/WebKit/Platform/IPC/MessageRe= ceiverMap.cpp:129 #32 0x00007ffff0a9d39c in non-virtual thunk to WebKit::WebProcessProxy::did= ReceiveMessage(IPC::Connection&, IPC::Decoder&) () at /usr/src/debug/wpeweb= kit-2.44.2/Source/WebKit/UIProcess/WebProcessProxy.h:576 #33 0x00007ffff09bc3e5 in IPC::Connection::dispatchMessage () at /usr/src/debug/wpewebkit-2.44.2/Source/WebKit/Platform/IPC/Connectio= n.cpp:1292 #34 IPC::Connection::dispatchMessage () at /usr/src/debug/wpewebkit-2.44.2/Source/WebKit/Platform/IPC/Connectio= n.cpp:1247 #35 0x00007ffff09be701 in IPC::Connection::dispatchIncomingMessages () at /usr/src/debug/wpewebkit-2.44.2/Source/WebKit/Platform/IPC/Connectio= n.cpp:1412 #36 0x00007ffff257d0ae in WTF::Function::operator()() const () at /usr/src/debug/wpewebkit-2.44.2/Source/WTF/wtf/Function.h:82 #37 WTF::RunLoop::performWork () at /usr/src/debug/wpewebkit-2.44.2/Source/= WTF/wtf/RunLoop.cpp:147 #38 0x00007ffff25f62e9 in operator() () at /usr/src/debug/wpewebkit-2.44.2/= Source/WTF/wtf/glib/RunLoopGLib.cpp:80 #39 _FUN () at /usr/src/debug/wpewebkit-2.44.2/Source/WTF/wtf/glib/RunLoopG= Lib.cpp:82 #40 0x00007ffff25f6d5f in operator() () at /usr/src/debug/wpewebkit-2.44.2/= Source/WTF/wtf/glib/RunLoopGLib.cpp:53 #41 _FUN () at /usr/src/debug/wpewebkit-2.44.2/Source/WTF/wtf/glib/RunLoopG= Lib.cpp:56 #42 0x00007ffff6e76fb8 in ??? () at /lib64/libglib-2.0.so.0 #43 0x00007ffff6e79349 in g_main_context_dispatch () at /lib64/libglib-2.0.= so.0 #44 0x0000000000758158 in xg_select (fds_lim=3D, rfds=3D, wfds=3D, efds=3D0x0, timeout=3D, sigmask=3D) at x= gselect.c:281 #45 0x00000000006f3986 in wait_reading_process_output (time_limit=3Dtime_limit@entry=3D0, nsecs=3Dnsecs@entry=3D0, read_kbd= =3Dread_kbd@entry=3D-1, do_display=3Dtrue, wait_for_cell=3Dwait_for_cell@en= try=3D0x0, wait_proc=3Dwait_proc@entry=3D0x0, just_wait_proc=3D0) at proces= s.c:5742 #46 0x00000000005f82cc in kbd_buffer_get_event (end_time=3D, used_mouse_menu=3D, kbp=3D<= synthetic pointer>) at keyboard.c:4094 #47 read_event_from_main_queue (used_mouse_menu=3D, local_getcjmp=3D, en= d_time=3D) at keyboard.c:2330 #48 read_decoded_event_from_main_queue (used_mouse_menu=3D, prev_event=3D, local= _getcjmp=3D, end_time=3D) at keyboard.c:2394 #49 read_char (commandflag=3D1, map=3Dmap@entry=3D0x19363e3, prev_event=3D0x0, used_m= ouse_menu=3Dused_mouse_menu@entry=3D0x7fffffffd9db, end_time=3Dend_time@ent= ry=3D0x0) at keyboard.c:3015 #50 0x00000000005fb8a9 in read_key_sequence (keybuf=3Dkeybuf@entry=3D0x7fffffffdb20, prompt=3Dprompt@entry=3D0x0, d= ont_downcase_last=3Ddont_downcase_last@entry=3Dfalse, can_return_switch_fra= me=3Dcan_return_switch_frame@entry=3Dtrue, fix_current_buffer=3Dfix_current= _buffer@entry=3Dtrue, prevent_redisplay=3Dprevent_redisplay@entry=3Dfalse, = disable_text_conversion_p=3Dfalse) at keyboard.c:10754 #51 0x00000000005fd4b9 in command_loop_1 () at keyboard.c:1429 #52 0x0000000000687bf7 in internal_condition_case (bfun=3Dbfun@entry=3D0x5fd270 , handlers=3Dhandlers@ent= ry=3D0x90, hfun=3Dhfun@entry=3D0x5f0c00 ) at eval.c:1613 #53 0x00000000005e70ea in command_loop_2 (handlers=3Dhandlers@entry=3D0x90)= at keyboard.c:1168 #54 0x0000000000687a91 in internal_catch (tag=3Dtag@entry=3D0x123c0, func=3Dfunc@entry=3D0x5e70d0 , arg=3Darg@entry=3D0x90) at eval.c:1292 #55 0x00000000005e708f in command_loop () at keyboard.c:1146 #56 0x00000000005f0723 in recursive_edit_1 () at keyboard.c:754 #57 0x00000000005f0a8b in Frecursive_edit () at keyboard.c:837 #58 0x0000000000491be1 in main (argc=3D, argv=3D) at emacs.c:2624