cht電腦資訊gcin
adm Find login register

Qt5 im-module 會造成 KDE 無法啟動

siyuan
joined: 2012-01-04
posted: 13
promoted:
bookmarked:
紐西蘭
1subject: Qt5 im-module 會造成 KDE 無法啟動Promote 0 Bookmark 02016-01-02quote  

問題的細節不太清除,應該是一種 race condition 吧。當 KDE 啟動時,第一個啟動的 X 程式是 ksplashqml,這是顯示進度用的。這時 Qt 會載入一些 plugin,其中包括 gcin 的 plugin。然而 gcin 的 qt5-im plugin 執行到 gcin_im_client_open(display) 時,ksplashqml 就被卡死在這了。

QGcinPlatformInputContext::QGcinPlatformInputContext() 
{
    dbg("QGcinPlatformInputContext::QGcinPlatformInputContext() \n");
    QPlatformNativeInterface *native = QGuiApplication::platformNativeInterface();
    if(!native)
        return;
    Display *display = static_cast<Display *>(native->nativeResourceForWindow("display", NULL));	
    
    if (!(gcin_ch = gcin_im_client_open(display))) {
        perror("cannot open gcin_ch");
        dbg("gcin_im_client_open error\n");
        return;
    }
  
    dbg("QGcinPlatformInputContext succ\n");
}

目前我找到的解決方案有兩個:

  1. 在 ~/.xprofile 或 ~/.xinitrc 裡先啟動 gcin
  2. 延遲執行 gcin_im_client_open()
    QGcinPlatformInputContext::QGcinPlatformInputContext() 
    {
        dbg("QGcinPlatformInputContext::QGcinPlatformInputContext() \n");
        QTimer::singleShot(0, this, &QGcinPlatformInputContext::gcinImClientOpen);
        dbg("QGcinPlatformInputContext succ\n");
    }
    
    void QGcinPlatformInputContext::gcinImClientOpen()
    {
        QPlatformNativeInterface *native = QGuiApplication::platformNativeInterface();
        if(!native)
            return;
        Display *display = static_cast<Display *>(native->nativeResourceForWindow("display", NULL));	
        
        if (!(gcin_ch = gcin_im_client_open(display))) {
            perror("cannot open gcin_ch");
            dbg("gcin_im_client_open error\n");
            return;
        }
    }

不知道哪種方法比較正確?

cht電腦資訊gcin
adm Find login register
views:3068