gtk/mobile.cpp | 35 ++++++++++++++++++++++++----------- kit/Kit.cpp | 12 +++++++----- 2 files changed, 31 insertions(+), 16 deletions(-)
New commits: commit fc2023723e9a9e9cb2afc9436ce5db652d390464 Author: Tor Lillqvist <t...@collabora.com> AuthorDate: Wed Oct 17 23:25:28 2018 +0300 Commit: Tor Lillqvist <t...@collabora.com> CommitDate: Wed Oct 17 23:30:26 2018 +0300 Attempt to fix the thread problems in the GTK+ testbed app Use g_idle_add() to make the webkit_web_view_run_javascript() call run on the GTK+ thread. Correspondingly, need to use a separate short-lived thread to do the fakeSocketWrite() calls from handle_lool_message(), so that the GTK+ main loop is ready to run the added lambda. Or something like that. Now it gets a bit further, doesn't crash, but just sudddenly exits before showing the document even. diff --git a/gtk/mobile.cpp b/gtk/mobile.cpp index b28e9129b..760d62c10 100644 --- a/gtk/mobile.cpp +++ b/gtk/mobile.cpp @@ -113,7 +113,12 @@ static void send2JS(const std::vector<char>& buffer) LOG_TRC_NOFILE( "Evaluating JavaScript: " << subjs); char *jscopy = strdup(js.c_str()); - webkit_web_view_run_javascript(webView, jscopy, NULL, send2JS_ready_callback, jscopy); + g_idle_add([](gpointer data) + { + char *jscopy = (char*) data; + webkit_web_view_run_javascript(webView, jscopy, NULL, send2JS_ready_callback, jscopy); + return FALSE; + }, jscopy); } static void handle_debug_message(WebKitUserContentManager *manager, @@ -201,11 +206,15 @@ static void handle_lool_message(WebKitUserContentManager *manager, // WebSocket. LOG_TRC_NOFILE("Actually sending to Online:" << fileURL); - struct pollfd pollfd; - pollfd.fd = fakeClientFd; - pollfd.events = POLLOUT; - fakeSocketPoll(&pollfd, 1, -1); - fakeSocketWrite(fakeClientFd, fileURL.c_str(), fileURL.size()); + // Must do this in a thread, too, so that we can return to the GTK+ main loop + std::thread([] + { + struct pollfd pollfd; + pollfd.fd = fakeClientFd; + pollfd.events = POLLOUT; + fakeSocketPoll(&pollfd, 1, -1); + fakeSocketWrite(fakeClientFd, fileURL.c_str(), fileURL.size()); + }).detach(); } else if (strcmp(string_value, "BYE") == 0) { @@ -218,11 +227,15 @@ static void handle_lool_message(WebKitUserContentManager *manager, } else { - struct pollfd pollfd; - pollfd.fd = fakeClientFd; - pollfd.events = POLLOUT; - fakeSocketPoll(&pollfd, 1, -1); - fakeSocketWrite(fakeClientFd, string_value, strlen(string_value)); + // As above + std::thread([&] + { + struct pollfd pollfd; + pollfd.fd = fakeClientFd; + pollfd.events = POLLOUT; + fakeSocketPoll(&pollfd, 1, -1); + fakeSocketWrite(fakeClientFd, string_value, strlen(string_value)); + }).detach(); } g_free(string_value); } diff --git a/kit/Kit.cpp b/kit/Kit.cpp index 10e1cb48b..abd4eabfe 100644 --- a/kit/Kit.cpp +++ b/kit/Kit.cpp @@ -2454,14 +2454,16 @@ void lokit_main( #else // MOBILEAPP +#ifdef __linux + LibreOfficeKit *kit = lok_init_2(LO_PATH "/program", LO_PATH "/user"); +#else LibreOfficeKit *kit = lok_init_2(nullptr, nullptr); +#endif + + assert(kit); std::shared_ptr<lok::Office> loKit = std::make_shared<lok::Office>(kit); - if (!loKit) - { - LOG_FTL("LibreOfficeKit initialization failed. Exiting."); - std::_Exit(Application::EXIT_SOFTWARE); - } + assert(loKit); LOOLWSD::LOKitVersion = loKit->getVersionInfo(); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits