* Calling interactive lisp functions from C
@ 2024-09-22 16:38 Noé Lopez via Emacs development discussions.
0 siblings, 0 replies; 4+ messages in thread
From: Noé Lopez via Emacs development discussions. @ 2024-09-22 16:38 UTC (permalink / raw)
To: emacs-devel
Hi,
I am trying to call the read-file-name function from a C WebKit
callback, in this case it is the « run-file-chooser » signal.
I came up with this code which works when selecting a file, but aborts
emacs when hitting the « cancel » button of the file 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 = 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[] = { 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
« waiting_for_input » 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é Lopez
Backtrace:
#0 0x00007fffed094c5c in __pthread_kill_implementation () at /lib64/libc.so.6
#1 0x00007fffed0411c6 in raise () at /lib64/libc.so.6
#2 0x00000000004796b8 in terminate_due_to_signal (sig=sig@entry=6, backtrace_limit=backtrace_limit@entry=40)
at emacs.c:470
#3 0x000000000047b44c in emacs_abort () at sysdep.c:2391
#4 0x0000000000483ac5 in signal_or_quit
(error_symbol=error_symbol@entry=0xf8d0, data=data@entry=0x0, continuable=continuable@entry=true)
at eval.c:1858
#5 0x0000000000689ee5 in quit () at eval.c:1830
#6 0x00000000005bfa4a in Fx_file_dialog
(prompt=<optimized out>, dir=<optimized out>, default_filename=0x0, mustmatch=0x30, only_dir_p=0x0)
at xfns.c:9658
#7 0x00000000006dc917 in exec_byte_code (fun=0x7bdc, args_template=31708, nargs=5, args=0x7fffe7e00130)
at /home/noe/src/emacs/src/lisp.h:2243
#8 0x000000000068c928 in Ffuncall (nargs=nargs@entry=5, args=args@entry=0x7fffffffb960) at eval.c:3093
#9 0x0000000000721e87 in wpe_run_file_chooser_cb (webview=<optimized out>, xw=<optimized out>, request=0x1dbc770)
at xwidget-wpe.c:636
#10 wpe_run_file_chooser_cb (webview=<optimized out>, request=0x1dbc770, xw=<optimized out>) 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/libgobject-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/WebKitWebView.cpp:2855
#21 0x00007ffff0bb3243 in UIClient::runOpenPanel ()
at /usr/src/debug/wpewebkit-2.44.2/Source/WebKit/UIProcess/API/glib/WebKitUIClient.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::WebPageProxy, WebKit::WebPageProxy, void (WebCore::ProcessQualified<WTF::ObjectIdentifierGeneric<WebCore::FrameIdentifierType, WTF::ObjectIdentifierMainThreadAccessTraits> >, WebKit::FrameInfoData&&, WebCore::FileChooserSettings const&), std::tuple<WebCore::ProcessQualified<WTF::ObjectIdentifierGeneric<WebCore::FrameIdentifierType, WTF::ObjectIdentifierMainThreadAccessTraits> >, WebKit::FrameInfoData, WebCore::FileChooserSettings> >(WebKit::WebPageProxy*, void (WebKit::WebPageProxy::*)(WebCore::ProcessQualified<WTF::ObjectIdentifierGeneric<WebCore::FrameIdentifierType, WTF::ObjectIdentifierMainThreadAccessTraits> >, WebKit::FrameInfoData&&, WebCore::FileChooserSettings const&), std::tuple<WebCore::ProcessQualified<WTF::ObjectIdentifierGeneric<WebCore::FrameIdentifierType, WTF::ObjectIdentifierMainThreadAccessTraits> >, WebKit::FrameInfoData, WebCore::FileChooserSettings>&&)::{lambda((auto:1&&)...)#1}::operator()<WebCore::ProcessQualified<WTF::ObjectIdentifierGeneric<WebCore::FrameIdentifierType, WTF::ObjectIdentifierMainThreadAccessTraits> >, WebKit::FrameInfoData, WebCore::FileChooserSettings>(WebCore::ProcessQualified<WTF::ObjectIdentifierGeneric<WebCore::FrameIdentifierType, WTF::ObjectIdentifierMainThreadAccessTraits> >&&, WebKit::FrameInfoData&&, WebCore::FileChooserSettings&&) const ()
at /usr/src/debug/wpewebkit-2.44.2/Source/WebKit/Platform/IPC/HandleMessage.h:136
#24 std::__invoke_impl<void, IPC::callMemberFunction<WebKit::WebPageProxy, WebKit::WebPageProxy, void (WebCore::ProcessQualified<WTF::ObjectIdentifierGeneric<WebCore::FrameIdentifierType, WTF::ObjectIdentifierMainThreadAccessTraits> >, WebKit::FrameInfoData&&, WebCore::FileChooserSettings const&), std::tuple<WebCore::ProcessQualified<WTF::ObjectIdentifierGeneric<WebCore::FrameIdentifierType, WTF::ObjectIdentifierMainThreadAccessTraits> >, WebKit::FrameInfoData, WebCore::FileChooserSettings> >(WebKit::WebPageProxy*, void (WebKit::WebPageProxy::*)(WebCore::ProcessQualified<WT--Type <RET> for more, q to quit, c to continue without paging--c
F::ObjectIdentifierGeneric<WebCore::FrameIdentifierType, WTF::ObjectIdentifierMainThreadAccessTraits> >, WebKit::FrameInfoData&&, WebCore::FileChooserSettings const&), std::tuple<WebCore::ProcessQualified<WTF::ObjectIdentifierGeneric<WebCore::FrameIdentifierType, WTF::ObjectIdentifierMainThreadAccessTraits> >, WebKit::FrameInfoData, WebCore::FileChooserSettings>&&)::{lambda((auto:1&&)...)#1}, WebCore::ProcessQualified<WTF::ObjectIdentifierGeneric<WebCore::FrameIdentifierType, WTF::ObjectIdentifierMainThreadAccessTraits> >, WebKit::FrameInfoData, WebCore::FileChooserSettings>(std::__invoke_other, IPC::callMemberFunction<WebKit::WebPageProxy, WebKit::WebPageProxy, void (WebCore::ProcessQualified<WTF::ObjectIdentifierGeneric<WebCore::FrameIdentifierType, WTF::ObjectIdentifierMainThreadAccessTraits> >, WebKit::FrameInfoData&&, WebCore::FileChooserSettings const&), std::tuple<WebCore::ProcessQualified<WTF::ObjectIdentifierGeneric<WebCore::FrameIdentifierType, WTF::ObjectIdentifierMainThreadAccessTraits> >, WebKit::FrameInfoData, WebCore::FileChooserSettings> >(WebKit::WebPageProxy*, void (WebKit::WebPageProxy::*)(WebCore::ProcessQualified<WTF::ObjectIdentifierGeneric<WebCore::FrameIdentifierType, WTF::ObjectIdentifierMainThreadAccessTraits> >, WebKit::FrameInfoData&&, WebCore::FileChooserSettings const&), std::tuple<WebCore::ProcessQualified<WTF::ObjectIdentifierGeneric<WebCore::FrameIdentifierType, WTF::ObjectIdentifierMainThreadAccessTraits> >, WebKit::FrameInfoData, WebCore::FileChooserSettings>&&)::{lambda((auto:1&&)...)#1}&&, WebCore::ProcessQualified<WTF::ObjectIdentifierGeneric<WebCore::FrameIdentifierType, WTF::ObjectIdentifierMainThreadAccessTraits> >&&, WebKit::FrameInfoData&&, WebCore::FileChooserSettings&&) () at /usr/include/c++/14/bits/invoke.h:61
#25 std::__invoke<IPC::callMemberFunction<WebKit::WebPageProxy, WebKit::WebPageProxy, void (WebCore::ProcessQualified<WTF::ObjectIdentifierGeneric<WebCore::FrameIdentifierType, WTF::ObjectIdentifierMainThreadAccessTraits> >, WebKit::FrameInfoData&&, WebCore::FileChooserSettings const&), std::tuple<WebCore::ProcessQualified<WTF::ObjectIdentifierGeneric<WebCore::FrameIdentifierType, WTF::ObjectIdentifierMainThreadAccessTraits> >, WebKit::FrameInfoData, WebCore::FileChooserSettings> >(WebKit::WebPageProxy*, void (WebKit::WebPageProxy::*)(WebCore::ProcessQualified<WTF::ObjectIdentifierGeneric<WebCore::FrameIdentifierType, WTF::ObjectIdentifierMainThreadAccessTraits> >, WebKit::FrameInfoData&&, WebCore::FileChooserSettings const&), std::tuple<WebCore::ProcessQualified<WTF::ObjectIdentifierGeneric<WebCore::FrameIdentifierType, WTF::ObjectIdentifierMainThreadAccessTraits> >, WebKit::FrameInfoData, WebCore::FileChooserSettings>&&)::{lambda((auto:1&&)...)#1}, WebCore::ProcessQualified<WTF::ObjectIdentifierGeneric<WebCore::FrameIdentifierType, WTF::ObjectIdentifierMainThreadAccessTraits> >, WebKit::FrameInfoData, WebCore::FileChooserSettings>(IPC::callMemberFunction<WebKit::WebPageProxy, WebKit::WebPageProxy, void (WebCore::ProcessQualified<WTF::ObjectIdentifierGeneric<WebCore::FrameIdentifierType, WTF::ObjectIdentifierMainThreadAccessTraits> >, WebKit::FrameInfoData&&, WebCore::FileChooserSettings const&), std::tuple<WebCore::ProcessQualified<WTF::ObjectIdentifierGeneric<WebCore::FrameIdentifierType, WTF::ObjectIdentifierMainThreadAccessTraits> >, WebKit::FrameInfoData, WebCore::FileChooserSettings> >(WebKit::WebPageProxy*, void (WebKit::WebPageProxy::*)(WebCore::ProcessQualified<WTF::ObjectIdentifierGeneric<WebCore::FrameIdentifierType, WTF::ObjectIdentifierMainThreadAccessTraits> >, WebKit::FrameInfoData&&, WebCore::FileChooserSettings const&), std::tuple<WebCore::ProcessQualified<WTF::ObjectIdentifierGeneric<WebCore::FrameIdentifierType, WTF::ObjectIdentifierMainThreadAccessTraits> >, WebKit::FrameInfoData, WebCore::FileChooserSettings>&&)::{lambda((auto:1&&)...)#1}&&, WebCore::ProcessQualified<WTF::ObjectIdentifierGeneric<WebCore::FrameIdentifierType, WTF::ObjectIdentifierMainThreadAccessTraits> >&&, WebKit::FrameInfoData&&, WebCore::FileChooserSettings&&) ()
at /usr/include/c++/14/bits/invoke.h:96
#26 std::__apply_impl<IPC::callMemberFunction<WebKit::WebPageProxy, WebKit::WebPageProxy, void (WebCore::ProcessQualified<WTF::ObjectIdentifierGeneric<WebCore::FrameIdentifierType, WTF::ObjectIdentifierMainThreadAccessTraits> >, WebKit::FrameInfoData&&, WebCore::FileChooserSettings const&), std::tuple<WebCore::ProcessQualified<WTF::ObjectIdentifierGeneric<WebCore::FrameIdentifierType, WTF::ObjectIdentifierMainThreadAccessTraits> >, WebKit::FrameInfoData, WebCore::FileChooserSettings> >(WebKit::WebPageProxy*, void (WebKit::WebPageProxy::*)(WebCore::ProcessQualified<WTF::ObjectIdentifierGeneric<WebCore::FrameIdentifierType, WTF::ObjectIdentifierMainThreadAccessTraits> >, WebKit::FrameInfoData&&, WebCore::FileChooserSettings const&), std::tuple<WebCore::ProcessQualified<WTF::ObjectIdentifierGeneric<WebCore::FrameIdentifierType, WTF::ObjectIdentifierMainThreadAccessTraits> >, WebKit::FrameInfoData, WebCore::FileChooserSettings>&&)::{lambda((auto:1&&)...)#1}, std::tuple<WebCore::ProcessQualified<WTF::ObjectIdentifierGeneric<WebCore::FrameIdentifierType, WTF::ObjectIdentifierMainThreadAccessTraits> >, WebKit::FrameInfoData, WebCore::FileChooserSettings>, 0ul, 1ul, 2ul>(IPC::callMemberFunction<WebKit::WebPageProxy, WebKit::WebPageProxy, void (WebCore::ProcessQualified<WTF::ObjectIdentifierGeneric<WebCore::FrameIdentifierType, WTF::ObjectIdentifierMainThreadAccessTraits> >, WebKit::FrameInfoData&&, WebCore::FileChooserSettings const&), std::tuple<WebCore::ProcessQualified<WTF::ObjectIdentifierGeneric<WebCore::FrameIdentifierType, WTF::ObjectIdentifierMainThreadAccessTraits> >, WebKit::FrameInfoData, WebCore::FileChooserSettings> >(WebKit::WebPageProxy*, void (WebKit::WebPageProxy::*)(WebCore::ProcessQualified<WTF::ObjectIdentifierGeneric<WebCore::FrameIdentifierType, WTF::ObjectIdentifierMainThreadAccessTraits> >, WebKit::FrameInfoData&&, WebCore::FileChooserSettings const&), std::tuple<WebCore::ProcessQualified<WTF::ObjectIdentifierGeneric<WebCore::FrameIdentifierType, WTF::ObjectIdentifierMainThreadAccessTraits> >, WebKit::FrameInfoData, WebCore::FileChooserSettings>&&)::{lambda((auto:1&&)...)#1}&&, std::tuple<WebCore::ProcessQualified<WTF::ObjectIdentifierGeneric<WebCore::FrameIdentifierType, WTF::ObjectIdentifierMainThreadAccessTraits> >, WebKit::FrameInfoData, WebCore::FileChooserSettings>&&, std::integer_sequence<unsigned long, 0ul, 1ul, 2ul>) () at /usr/include/c++/14/tuple:2921
#27 std::apply<IPC::callMemberFunction<WebKit::WebPageProxy, WebKit::WebPageProxy, void (WebCore::ProcessQualified<WTF::ObjectIdentifierGeneric<WebCore::FrameIdentifierType, WTF::ObjectIdentifierMainThreadAccessTraits> >, WebKit::FrameInfoData&&, WebCore::FileChooserSettings const&), std::tuple<WebCore::ProcessQualified<WTF::ObjectIdentifierGeneric<WebCore::FrameIdentifierType, WTF::ObjectIdentifierMainThreadAccessTraits> >, WebKit::FrameInfoData, WebCore::FileChooserSettings> >(WebKit::WebPageProxy*, void (WebKit::WebPageProxy::*)(WebCore::ProcessQualified<WTF::ObjectIdentifierGeneric<WebCore::FrameIdentifierType, WTF::ObjectIdentifierMainThreadAccessTraits> >, WebKit::FrameInfoData&&, WebCore::FileChooserSettings const&), std::tuple<WebCore::ProcessQualified<WTF::ObjectIdentifierGeneric<WebCore::FrameIdentifierType, WTF::ObjectIdentifierMainThreadAccessTraits> >, WebKit::FrameInfoData, WebCore::FileChooserSettings>&&)::{lambda((auto:1&&)...)#1}, std::tuple<WebCore::ProcessQualified<WTF::ObjectIdentifierGeneric<WebCore::FrameIdentifierType, WTF::ObjectIdentifierMainThreadAccessTraits> >, WebKit::FrameInfoData, WebCore::FileChooserSettings> >(IPC::callMemberFunction<WebKit::WebPageProxy, WebKit::WebPageProxy, void (WebCore::ProcessQualified<WTF::ObjectIdentifierGeneric<WebCore::FrameIdentifierType, WTF::ObjectIdentifierMainThreadAccessTraits> >, WebKit::FrameInfoData&&, WebCore::FileChooserSettings const&), std::tuple<WebCore::ProcessQualified<WTF::ObjectIdentifierGeneric<WebCore::FrameIdentifierType, WTF::ObjectIdentifierMainThreadAccessTraits> >, WebKit::FrameInfoData, WebCore::FileChooserSettings> >(WebKit::WebPageProxy*, void (WebKit::WebPageProxy::*)(WebCore::ProcessQualified<WTF::ObjectIdentifierGeneric<WebCore::FrameIdentifierType, WTF::ObjectIdentifierMainThreadAccessTraits> >, WebKit::FrameInfoData&&, WebCore::FileChooserSettings const&), std::tuple<WebCore::ProcessQualified<WTF::ObjectIdentifierGeneric<WebCore::FrameIdentifierType, WTF::ObjectIdentifierMainThreadAccessTraits> >, WebKit::FrameInfoData, WebCore::FileChooserSettings>&&)::{lambda((auto:1&&)...)#1}&&, std::tuple<WebCore::ProcessQualified<WTF::ObjectIdentifierGeneric<WebCore::FrameIdentifierType, WTF::ObjectIdentifierMainThreadAccessTraits> >, WebKit::FrameInfoData, WebCore::FileChooserSettings>&&) ()
at /usr/include/c++/14/tuple:2936
#28 IPC::callMemberFunction<WebKit::WebPageProxy, WebKit::WebPageProxy, void (WebCore::ProcessQualified<WTF::ObjectIdentifierGeneric<WebCore::FrameIdentifierType, WTF::ObjectIdentifierMainThreadAccessTraits> >, WebKit::FrameInfoData&&, WebCore::FileChooserSettings const&), std::tuple<WebCore::ProcessQualified<WTF::ObjectIdentifierGeneric<WebCore::FrameIdentifierType, WTF::ObjectIdentifierMainThreadAccessTraits> >, WebKit::FrameInfoData, WebCore::FileChooserSettings> >(WebKit::WebPageProxy*, void (WebKit::WebPageProxy::*)(WebCore::ProcessQualified<WTF::ObjectIdentifierGeneric<WebCore::FrameIdentifierType, WTF::ObjectIdentifierMainThreadAccessTraits> >, WebKit::FrameInfoData&&, WebCore::FileChooserSettings const&), std::tuple<WebCore::ProcessQualified<WTF::ObjectIdentifierGeneric<WebCore::FrameIdentifierType, WTF::ObjectIdentifierMainThreadAccessTraits> >, WebKit::FrameInfoData, WebCore::FileChooserSettings>&&) ()
at /usr/src/debug/wpewebkit-2.44.2/Source/WebKit/Platform/IPC/HandleMessage.h:134
#29 IPC::handleMessage<Messages::WebPageProxy::RunOpenPanel, WebKit::WebPageProxy, WebKit::WebPageProxy, void (WebCore::ProcessQualified<WTF::ObjectIdentifierGeneric<WebCore::FrameIdentifierType, WTF::ObjectIdentifierMainThreadAccessTraits> >, WebKit::FrameInfoData&&, WebCore::FileChooserSettings const&)>(IPC::Connection&, IPC::Decoder&, WebKit::WebPageProxy*, void (WebKit::WebPageProxy::*)(WebCore::ProcessQualified<WTF::ObjectIdentifierGeneric<WebCore::FrameIdentifierType, WTF::ObjectIdentifierMainThreadAccessTraits> >, 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/WebPageProxyMessageReceiver.cpp:339
#31 0x00007ffff09c402d in IPC::MessageReceiverMap::dispatchMessage ()
at /usr/src/debug/wpewebkit-2.44.2/Source/WebKit/Platform/IPC/MessageReceiverMap.cpp:129
#32 0x00007ffff0a9d39c in non-virtual thunk to WebKit::WebProcessProxy::didReceiveMessage(IPC::Connection&, IPC::Decoder&) () at /usr/src/debug/wpewebkit-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/Connection.cpp:1292
#34 IPC::Connection::dispatchMessage ()
at /usr/src/debug/wpewebkit-2.44.2/Source/WebKit/Platform/IPC/Connection.cpp:1247
#35 0x00007ffff09be701 in IPC::Connection::dispatchIncomingMessages ()
at /usr/src/debug/wpewebkit-2.44.2/Source/WebKit/Platform/IPC/Connection.cpp:1412
#36 0x00007ffff257d0ae in WTF::Function<void ()>::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/RunLoopGLib.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/RunLoopGLib.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=<optimized out>, rfds=<optimized out>, wfds=<optimized out>, efds=0x0, timeout=<optimized out>, sigmask=<optimized out>) at xgselect.c:281
#45 0x00000000006f3986 in wait_reading_process_output
(time_limit=time_limit@entry=0, nsecs=nsecs@entry=0, read_kbd=read_kbd@entry=-1, do_display=true, wait_for_cell=wait_for_cell@entry=0x0, wait_proc=wait_proc@entry=0x0, just_wait_proc=0) at process.c:5742
#46 0x00000000005f82cc in kbd_buffer_get_event
(end_time=<optimized out>, used_mouse_menu=<optimized out>, kbp=<synthetic pointer>) at keyboard.c:4094
#47 read_event_from_main_queue
(used_mouse_menu=<optimized out>, local_getcjmp=<optimized out>, end_time=<optimized out>) at keyboard.c:2330
#48 read_decoded_event_from_main_queue
(used_mouse_menu=<optimized out>, prev_event=<optimized out>, local_getcjmp=<optimized out>, end_time=<optimized out>) at keyboard.c:2394
#49 read_char
(commandflag=1, map=map@entry=0x19363e3, prev_event=0x0, used_mouse_menu=used_mouse_menu@entry=0x7fffffffd9db, end_time=end_time@entry=0x0) at keyboard.c:3015
#50 0x00000000005fb8a9 in read_key_sequence
(keybuf=keybuf@entry=0x7fffffffdb20, prompt=prompt@entry=0x0, dont_downcase_last=dont_downcase_last@entry=false, can_return_switch_frame=can_return_switch_frame@entry=true, fix_current_buffer=fix_current_buffer@entry=true, prevent_redisplay=prevent_redisplay@entry=false, disable_text_conversion_p=false) at keyboard.c:10754
#51 0x00000000005fd4b9 in command_loop_1 () at keyboard.c:1429
#52 0x0000000000687bf7 in internal_condition_case
(bfun=bfun@entry=0x5fd270 <command_loop_1>, handlers=handlers@entry=0x90, hfun=hfun@entry=0x5f0c00 <cmd_error>)
at eval.c:1613
#53 0x00000000005e70ea in command_loop_2 (handlers=handlers@entry=0x90) at keyboard.c:1168
#54 0x0000000000687a91 in internal_catch
(tag=tag@entry=0x123c0, func=func@entry=0x5e70d0 <command_loop_2>, arg=arg@entry=0x90) 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=<optimized out>, argv=<optimized out>) at emacs.c:2624
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Calling interactive lisp functions from C
[not found] <87v7yn63tu.fsf@>
@ 2024-09-22 18:03 ` Eli Zaretskii
2024-09-22 18:24 ` Eli Zaretskii
2024-09-22 20:22 ` Noé Lopez via Emacs development discussions.
0 siblings, 2 replies; 4+ messages in thread
From: Eli Zaretskii @ 2024-09-22 18:03 UTC (permalink / raw)
To: Noé Lopez; +Cc: emacs-devel
> Date: Sun, 22 Sep 2024 18:38:53 +0200
> From: Noé Lopez via "Emacs development discussions." <emacs-devel@gnu.org>
>
> I am trying to call the read-file-name function from a C WebKit
> callback, in this case it is the « run-file-chooser » signal.
>
> I came up with this code which works when selecting a file, but aborts
> emacs when hitting the « cancel » button of the file 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 = 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[] = { 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
> « waiting_for_input » 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.
Did you try to bind inhibit-quit to the value t?
An alternative is not to call read-file-name directly, but instead
queue an input event that will invoke a command when processed, and
the command will call read-file-name.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Calling interactive lisp functions from C
2024-09-22 18:03 ` Eli Zaretskii
@ 2024-09-22 18:24 ` Eli Zaretskii
2024-09-22 20:22 ` Noé Lopez via Emacs development discussions.
1 sibling, 0 replies; 4+ messages in thread
From: Eli Zaretskii @ 2024-09-22 18:24 UTC (permalink / raw)
To: noe; +Cc: emacs-devel
> Date: Sun, 22 Sep 2024 21:03:28 +0300
> From: Eli Zaretskii <eliz@gnu.org>
> Cc: emacs-devel@gnu.org
>
> Did you try to bind inhibit-quit to the value t?
>
> An alternative is not to call read-file-name directly, but instead
> queue an input event that will invoke a command when processed, and
> the command will call read-file-name.
One caveat: these two ideas are 100% untested.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Calling interactive lisp functions from C
2024-09-22 18:03 ` Eli Zaretskii
2024-09-22 18:24 ` Eli Zaretskii
@ 2024-09-22 20:22 ` Noé Lopez via Emacs development discussions.
1 sibling, 0 replies; 4+ messages in thread
From: Noé Lopez via Emacs development discussions. @ 2024-09-22 20:22 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: emacs-devel
Eli Zaretskii <eliz@gnu.org> writes:
>> Date: Sun, 22 Sep 2024 18:38:53 +0200
>> From: Noé Lopez via "Emacs development discussions." <emacs-devel@gnu.org>
>>
>> I am trying to call the read-file-name function from a C WebKit
>> callback, in this case it is the « run-file-chooser » signal.
>>
>> I came up with this code which works when selecting a file, but aborts
>> emacs when hitting the « cancel » button of the file 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 = 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[] = { 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
>> « waiting_for_input » 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.
>
> Did you try to bind inhibit-quit to the value t?
Yes, but Fx_file_dialox, called from read-file-name calls quit directly
without checking inhibit-quit.
> An alternative is not to call read-file-name directly, but instead
> queue an input event that will invoke a command when processed, and
> the command will call read-file-name.
That is probably best, if WebKit supports asynchronous answering for
that signal. I will look into it.
Thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-09-22 20:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-22 16:38 Calling interactive lisp functions from C Noé Lopez via Emacs development discussions.
[not found] <87v7yn63tu.fsf@>
2024-09-22 18:03 ` Eli Zaretskii
2024-09-22 18:24 ` Eli Zaretskii
2024-09-22 20:22 ` Noé Lopez via Emacs development discussions.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).