Xlib XSENDEVENT在其他应用程序/过程中



我有两个库:ida和xida。
XIDA处理事件循环,并且每个应用程序/过程都有一个单个事件循环。这些库是通过回调函数"连接"的。

这正在与一个单个应用程序/过程中的事件一起使用...

现在,我注意到我可以将事件从一个应用发送到另一个应用程序。它需要的是另一个应用程序中的窗口句柄。因此,我编码了DBUS消息,我可以收到一个...

这也可以正常工作,但是看起来Xsendevent((的接收器只能使用函数及其参数,而没有成员变量!

在HPP中:

        Window mSection;
        Window Section(){
          return 0; // This is working
        }
        Window Section_A(){
          return this->mSection; // This raises a memory access error
        }
        int CheckEvents( IDA_A *vIDA_A, XEvent vEvent);
        static int Section_EventCallback(void* this_ptr, XEvent vEvent){
        IDA_A* nIDA_A = NULL;
        int nRet = 1;
            try{
                nIDA_A = static_cast < IDA_A* > (this_ptr);
            } catch (...) { return 0; }
            cout << "TEST " << nIDA_A->Section() << endl; // This is working, also with any other function
            cout << "TEST " << nIDA_A->mSection << endl; // This raises a memory access error, also with any other member variable
            cout << "TEST " << nIDA_A->Section_A() << endl; // This also raises a memory access error
            nRet =  nIDA_A->CheckEvents(nIDA_A, vEvent);
            nIDA_A = NULL;
            return nRet;
        }

在CPP中:

        int IDA_A::CheckEvents(IDA_A *vIDA_A, XEvent vEvent) {
        Window nWindow = vEvent.xany.window;
        cout << "TEST " <<  " -- " << nWindow  << endl; // This is working
        cout << "TEST " <<  " -- " << this->mSection  << endl; // This raises a memory access error
        return 1;
        }

它还需要使用成员变量什么?

问候
早期咬合

----------------------------------编辑:--------------------------------------------------------

这是XIDA的一部分,其中Xsendevents((到达(从事件循环中呼叫后(:

    int XIDA_A::Send_To_Callback(XEvent vEvent){
        for(int i = 0; i < (int) this->mVecEvCallback.size(); i++){
            if( *this->mVecEvCallback[i].pWindow == vEvent.xany.window ){
                if( vEvent.type == ClientMessage ) {
                    cout << "THIS XIDA CLIENT " << this->mIdent << endl;
                }
                s_EventCallback nEvCallback;
                nEvCallback = this->mVecEvCallback[i];
                nEvCallback.Callback (nEvCallback.this_Ptr, vEvent);
                return 1;
            }
        }
        return 0;
    }

,为此,它正在起作用,也可以进行成员变量。但是在艾达(Ida但这是相同的过程!
以及例如使用DBU,它正在工作...
我真的很想知道原因!

已解决。
我发现错误...

这个

    cIDAMessage nMsg;
    nMsg.Msg_Type = IDAMsg_EventCallback;
    nMsg.Lng_Send[0] = 0;
    nMsg.Para_Void[0] = (void*) &this->mSection;
    nMsg.Para_ThisPtr = (void*) this;
    nMsg.Para_CallbackPtr = (void*) &this->Section_EventCallback;
    this->XIDA_Callback(this->mXIDA_A_Ptr, &nMsg);

是初始化的一部分。

我忘记了设置

nMsg.Para_ThisPtr = (void*) this;

但是我仍然不明白...

static int Section_EventCallback(void* this_ptr, XEvent vEvent){
IDA_A* nIDA_A = NULL;
int nRet = 1;
    try{
        nIDA_A = static_cast < IDA_A* > (this_ptr);
    } catch (...) { return 0; }
    nRet =  nIDA_A->CheckEvents(nIDA_A, vEvent);
    nIDA_A = NULL;
    return nRet;
}

这里是/带有null的指针。
nida_a为什么不null,或者为什么没有引起错误,因为static_cast不能用null施放?
为什么功能工作,但不起作用?

你知道我的意思吗?

最新更新