BUG Report: Failed When a Native Event is Unhooked with with Multi-Heritance
来源:互联网 发布:html与php的嵌套 编辑:程序博客网 时间:2024/06/05 15:17
SYMPTOMS
CAUSE
这个问题发生在事件的接受者(event_receiver)是多继承类的情况下。在unhook的时候event的注入代码无法正确比较成员函数指针。WORKAROUND
这个问题可以使用下面的代码重现:
#include <stdio.h>
class A
{
int a;
};
class B
{
int b;
};
[event_source(native)]
class CSource
{
public:
__event void MyEvent(int nValue);
};
[event_receiver(native)]
class CReceiver : public A, public B //多继承
{
public:
void MyHandler1(int nValue) {
printf("MyHandler1 was called with value %d./n", nValue);
}
void MyHandler2(int nValue) {
printf("MyHandler2 was called with value %d./n", nValue);
}
};
int main() {
CSource source;
CReceiver receiver;
__unhook(&CSource::MyEvent, &source, &CReceiver::MyHandler2, &receiver);
__hook(&CSource::MyEvent, &source, &CReceiver::MyHandler1, &receiver);
__raise source.MyEvent(1);
__unhook(&CSource::MyEvent, &source, &CReceiver::MyHandler1, &receiver);//失败
__hook(&CSource::MyEvent, &source, &CReceiver::MyHandler2, &receiver);
__raise source.MyEvent(2);
__unhook(&CSource::MyEvent, &source, &CReceiver::MyHandler2, &receiver);//失败
}
运行结果
MyHandler1 was called with value 1.
MyHandler2 was called with value 2.
MyHandler1 was called with value 2.
MyHandler2没有被正确unhook。
The information in this article applies to:
- Microsoft Visual C++ .NET (2002)
- Microsoft Visual C++ .NET (2003)
- Visual C++ 2005 Express Edition Beta
- BUG Report: Failed When a Native Event is Unhooked with with Multi-Heritance
- What we do with a bug report?
- Failed to establish connection with report server
- The function default must be used with a prefix when a default namespace is not specified
- The function getXX must be used with a prefix when a default namespace is not specified
- The function size must be used with a prefix when a default namespace is not specified
- The function equals must be used with a prefix when a default namespace is not specified
- The function size must be used with a prefix when a default namespace is not specified
- 解决The function contains must be used with a prefix when a default namespace is
- VirtualLab-Creating a Report with Report Builder 3.0
- a bug related with extern
- Rescuing a running virtual machine with dd when datastore metadata is inacces
- Combine Multi-Threading Application with Event-Driven Model
- There is a board with
- a simple event loop with IOCP
- Installation failed with message INSTALL_FAILED_NO_MATCHING_ABIS: Failed to extract native libraries
- Installation failed with message INSTALL_FAILED_NO_MATCHING_ABIS: Failed to extract native libraries
- Installation failed with message INSTALL_FAILED_NO_MATCHING_ABIS: Failed to extract native librarie
- 将某一目录下的所有相同格式的 XML文件绑定到不同的DataGrid
- 请教SQL SERVER配置的问题
- GDI+编程简介
- 为什么Dreamweaver MX在预览网页的时候出现乱码?
- XP 风格的可拖动列、可排序、可改变宽度的DataGrid的例子
- BUG Report: Failed When a Native Event is Unhooked with with Multi-Heritance
- 利用WebClient和WebRequest类获得网页源代码
- XP 风格的可拖动列、排序的DataGrid的例子
- 揭开native event的面纱
- 实现类似Windows资源管理器的DataGrid
- 在后代码里创建DataGrid控件
- 在ASP.NET中杀死进程
- Repeater控件分页例子
- 如何在DataGrid绑定之前为DataSet添加新列