Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SYS(3095,oObject) has a bug
Message
From
28/11/2005 18:25:47
 
 
To
28/11/2005 17:47:47
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows 2000 SP4
Network:
Windows 2000 Pro
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01072326
Message ID:
01072642
Views:
13
Hi Fabio,

this code buggy.
? "external = ", SYS(3095,ox), "Internal ",ox.IDispatch

DEFINE CLASS myclass AS session OLEPUBLIC

	PROCEDURE IDispatch
		RETURN SYS(3095,CreateObject("myserver.myclass"))
ENDDEFINE
the pointers are different of course, cause your creating a temporary COM object in the line "RETURN SYS(..." which is released directly afterwards.

or to express it in code:
&& this
PROCEDURE IDispatch
 RETURN SYS(3095,CreateObject("myserver.myclass"))
&& is the same as this
PROCEDURE IDispatch
 LOCAL loObj
 loObj = CreateObject("myserver.myclass")
 RETURN SYS(3095,loObj)
ENDPROC
so IDispatch() would return a pointer that is invalid for subsequent use, which you can easily verify:
LOCAL IExternal, IInternal, ox, ox2
ox = CreateObject("myserver.myclass")    && create the server object
IExternal = SYS(3095,ox)
IInternal = ox.IDispatch()

ox2 = SYS(3096,IExternal)
? ox = ox2
ox2 = SYS(3096,IInternal) && this completly crashes VFP9 with error ".. pure virtual function call .. " cause the pointer isn't valid anymore
Regards
Christian
Previous
Reply
Map
View

Click here to load this message in the networking platform