fixed IDEA-200822 Opening any Markdown file freezes recent IntelliJ Ultimate EAP... pycharm/191.729 pycharm/191.730 rubymine/191.727 rubymine/191.732 webstorm/191.728
authorArtem Bochkarev <artem.bochkarev@jetbrains.com>
Fri, 19 Oct 2018 09:45:45 +0000 (16:45 +0700)
committerArtem Bochkarev <artem.bochkarev@jetbrains.com>
Wed, 24 Oct 2018 02:41:01 +0000 (09:41 +0700)
bin/linux/libdbm64.so
native/LinuxGlobalMenu/DbusMenuWrapper.c
native/LinuxGlobalMenu/DbusMenuWrapper.h
platform/platform-impl/src/com/intellij/openapi/wm/impl/GlobalMenuLinux.java

index f28323c7bd36a2bde85eb30383c9e33f520527bb..a2ed4f7b04f4a78470a3e2c19cc0d0ec8a299b99 100755 (executable)
Binary files a/bin/linux/libdbm64.so and b/bin/linux/libdbm64.so differ
index b131494e291347a038017ac49706234c4981c316..da30f1af88290c42afcba24d5d5feab065c4b1f6 100644 (file)
@@ -18,7 +18,6 @@
 #define  MENUITEM_JHANDLER_PROPERTY "com.intellij.idea.globalmenu.jhandler"
 #define  MENUITEM_UID_PROPERTY "com.intellij.idea.globalmenu.uid"
 
-static GMainLoop *_ourMainLoop = NULL;
 static jlogger _ourLogger = NULL;
 static jrunnable _ourOnServiceAppearedCallback = NULL;
 static jrunnable _ourOnServiceVanishedCallback = NULL;
@@ -79,19 +78,17 @@ static void _onNameVanished(GDBusConnection *connection, const gchar *name, gpoi
     (*((jrunnable) _ourOnServiceVanishedCallback))();
 }
 
-void runDbusServer(jlogger jlog, jrunnable onAppmenuServiceAppeared, jrunnable onAppmenuServiceVanished) {
+void startWatchDbus(jlogger jlog, jrunnable onAppmenuServiceAppeared, jrunnable onAppmenuServiceVanished) {
   // NOTE: main-loop is necessary for communication with dbus (via glib and it's signals)
+  // It is started in java (see invocation com.sun.javafx.application.PlatformImpl.startup())
   _ourLogger = jlog;
-  _ourMainLoop = g_main_loop_new(NULL/*will be used g_main_context_default()*/, FALSE);
   _ourOnServiceAppearedCallback = onAppmenuServiceAppeared;
   _ourOnServiceVanishedCallback = onAppmenuServiceVanished;
   _ourServiceNameWatcher = g_bus_watch_name(G_BUS_TYPE_SESSION, DBUS_NAME, G_BUS_NAME_WATCHER_FLAGS_NONE, _onNameAppeared, _onNameVanished, NULL, NULL);
-  _info("glib main loop is running");
-  g_main_loop_run(_ourMainLoop);
+  // _info("start watching for dbus name 'com.canonical.AppMenu.Registrar'");
 }
 
-void stopDbusServer() {
-  g_main_loop_quit(_ourMainLoop);
+void stopWatchDbus() {
   g_bus_unwatch_name(_ourServiceNameWatcher);
   // _info("glib main loop is stopped");
 }
index 1aa7b91a91d13581b9c889aef6a80fe64f2ac238..bc023f36b81c0453a94018a19f71a5d8051e2a42 100644 (file)
@@ -37,8 +37,8 @@ extern "C"{
 
 // runs main loop of glib (which is needed to communicate with dbus)
 // must be called from java thread (to avoid detach, so jna-callbacks will be invoked from same thread)
-void runDbusServer(jlogger jlogger, jrunnable onAppmenuServiceAppeared, jrunnable onAppmenuServiceVanished);
-void stopDbusServer();
+void startWatchDbus(jlogger jlogger, jrunnable onAppmenuServiceAppeared, jrunnable onAppmenuServiceVanished);
+void stopWatchDbus();
 void execOnMainLoop(jrunnable run);
 
 WndInfo* registerWindow(long windowXid, jeventcallback handler); // creates menu-server and binds to xid
index 568ee58337b43c9d34c53b4bf34bfebe6937bc06..40a3c3db41a7ca483b57744290bd0716defd511f 100644 (file)
@@ -35,9 +35,11 @@ import java.text.SimpleDateFormat;
 import java.util.List;
 import java.util.concurrent.ConcurrentHashMap;
 
+import com.sun.javafx.application.PlatformImpl;
+
 interface GlobalMenuLib extends Library {
-  void runDbusServer(JLogger jlogger, JRunnable onAppmenuServiceAppeared, JRunnable onAppmenuServiceVanished);
-  void stopDbusServer();
+  void startWatchDbus(JLogger jlogger, JRunnable onAppmenuServiceAppeared, JRunnable onAppmenuServiceVanished);
+  void stopWatchDbus();
   void execOnMainLoop(JRunnable run);
 
   Pointer registerWindow(long windowXid, EventHandler handler);
@@ -109,7 +111,6 @@ public class GlobalMenuLinux implements GlobalMenuLib.EventHandler, Disposable {
   private static final Logger LOG = Logger.getInstance(GlobalMenuLinux.class);
   private static final GlobalMenuLib ourLib;
   private static final GlobalMenuLib.JLogger ourGLogger;
-  private static final Thread ourGlibMainLoopThread;
   private static final GlobalMenuLib.JRunnable ourProcessQueue;
   private static final GlobalMenuLib.JRunnable ourOnAppmenuServiceAppeared;
   private static final GlobalMenuLib.JRunnable ourOnAppmenuServiceVanished;
@@ -148,13 +149,13 @@ public class GlobalMenuLinux implements GlobalMenuLib.EventHandler, Disposable {
       };
       ourOnAppmenuServiceAppeared = () -> {
         // exec at glib-thread
-        _trace("Appeared dbus-service 'com.canonical.AppMenu.Registrar'");
+        LOG.info("Appeared dbus-service 'com.canonical.AppMenu.Registrar'");
         ourIsServiceAvailable = true;
         ourProcessQueue.run();
       };
       ourOnAppmenuServiceVanished = () -> {
         // exec at glib-thread
-        _trace("Closed dbus-service 'com.canonical.AppMenu.Registrar'");
+        LOG.info("Closed dbus-service 'com.canonical.AppMenu.Registrar'");
         ourIsServiceAvailable = false;
         for (GlobalMenuLinux gml: ourInstances.values()) {
           gml.myWindowHandle = null;
@@ -162,11 +163,12 @@ public class GlobalMenuLinux implements GlobalMenuLib.EventHandler, Disposable {
         }
       };
 
-      ourGlibMainLoopThread = new Thread(()->ourLib.runDbusServer(ourGLogger, ourOnAppmenuServiceAppeared, ourOnAppmenuServiceVanished), "Glib-main-loop");
-      ourGlibMainLoopThread.start();
+      // NOTE: linux implementation of javaFX starts native main loop with GtkApplication._runLoop()
+      PlatformImpl.startup(()-> {
+        ourLib.startWatchDbus(ourGLogger, ourOnAppmenuServiceAppeared, ourOnAppmenuServiceVanished);
+      });
     } else {
       ourGLogger = null;
-      ourGlibMainLoopThread = null;
       ourProcessQueue = null;
       ourOnAppmenuServiceAppeared = null;
       ourOnAppmenuServiceVanished = null;