Bug 1317604 - 3. Don't create EventDispatcher when JNI is not available; r=me
authorJim Chen <nchen@mozilla.com>
Mon, 21 Nov 2016 14:14:32 -0500
changeset 323724 99875ec5d316c768ad7f1e3de5ec400055b25233
parent 323723 9ef303d80d12ed1f29d833d578eac2a61f556d3c
child 323725 853024720c07fcc93af81019004ce4132fe9eb89
push id21
push usermaklebus@msu.edu
push dateThu, 01 Dec 2016 06:22:08 +0000
reviewersme
bugs1317604
milestone53.0a1
Bug 1317604 - 3. Don't create EventDispatcher when JNI is not available; r=me Follow-up to not create the global EventDispatcher in AndroidBridge when JNI is not available.
widget/android/AndroidBridge.cpp
widget/android/AndroidBridge.h
--- a/widget/android/AndroidBridge.cpp
+++ b/widget/android/AndroidBridge.cpp
@@ -733,20 +733,22 @@ AndroidBridge::GetGlobalContextRef() {
     return sGlobalContext;
 }
 
 /* Implementation file */
 NS_IMPL_ISUPPORTS(nsAndroidBridge, nsIAndroidEventDispatcher, nsIAndroidBridge)
 
 nsAndroidBridge::nsAndroidBridge()
 {
-  RefPtr<widget::EventDispatcher> dispatcher = new widget::EventDispatcher();
-  dispatcher->Attach(java::EventDispatcher::GetInstance(),
-                     /* window */ nullptr);
-  mEventDispatcher = dispatcher;
+  if (jni::IsAvailable()) {
+    RefPtr<widget::EventDispatcher> dispatcher = new widget::EventDispatcher();
+    dispatcher->Attach(java::EventDispatcher::GetInstance(),
+                       /* window */ nullptr);
+    mEventDispatcher = dispatcher;
+  }
 
   AddObservers();
 }
 
 nsAndroidBridge::~nsAndroidBridge()
 {
   RemoveObservers();
 }
--- a/widget/android/AndroidBridge.h
+++ b/widget/android/AndroidBridge.h
@@ -398,17 +398,17 @@ private:
 class nsAndroidBridge final : public nsIAndroidBridge,
                               public nsIObserver
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIANDROIDBRIDGE
   NS_DECL_NSIOBSERVER
 
-  NS_FORWARD_NSIANDROIDEVENTDISPATCHER(mEventDispatcher->)
+  NS_FORWARD_SAFE_NSIANDROIDEVENTDISPATCHER(mEventDispatcher)
 
   nsAndroidBridge();
 
 private:
   ~nsAndroidBridge();
 
   void AddObservers();
   void RemoveObservers();