Commit b330c828 authored by Karl Tomlinson's avatar Karl Tomlinson
Browse files

Bug 1824634 hold GtkIMContext reference a little longer than preedit-changed a=RyanVM

parent bc4926c1
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ GOBJECT_TRAITS(GdkDragContext)
GOBJECT_TRAITS(GDBusMessage)
GOBJECT_TRAITS(GdkPixbuf)
GOBJECT_TRAITS(GCancellable)
GOBJECT_TRAITS(GtkIMContext)
GOBJECT_TRAITS(GUnixFDList)

#ifdef MOZ_ENABLE_DBUS
+13 −1
Original line number Diff line number Diff line
@@ -10,6 +10,8 @@
#include "prenv.h"

#include "IMContextWrapper.h"

#include "GRefPtr.h"
#include "nsGtkKeyUtils.h"
#include "nsWindow.h"
#include "mozilla/AutoRestore.h"
@@ -1728,7 +1730,17 @@ void IMContextWrapper::OnEndCompositionNative(GtkIMContext* aContext) {
/* static */
void IMContextWrapper::OnChangeCompositionCallback(GtkIMContext* aContext,
                                                   IMContextWrapper* aModule) {
  aModule->OnChangeCompositionNative(aContext);
  RefPtr module = aModule;
  module->OnChangeCompositionNative(aContext);

  if (module->IsDestroyed()) {
    // A strong reference is already held during "preedit-changed" emission,
    // but _ibus_context_destroy_cb() in ibus 1.5.28 and
    // _fcitx_im_context_close_im_cb() in fcitx 4.2.9.9 want their
    // GtkIMContexts to live a little longer.  See bug 1824634.
    NS_DispatchToMainThread(
        NS_NewRunnableFunction(__func__, [context = RefPtr{aContext}]() {}));
  }
}

void IMContextWrapper::OnChangeCompositionNative(GtkIMContext* aContext) {