I'm forwarding this report/question I received to my personal e-mail:

---
Hello Viktor,

I make for you a little test how hb_objSendMsg() fail and create GPF.

Please can you chek ??

Best Regards,
Fernando

------------- PRG ----------------
#include "HBCLASS.CH"

FUNCTION MAIN()

 LOCAL oSon

 // Initialize Hash
 InitMyHash()

 oSon := MySon():New()

 oSon:Link()

 GetMsgFromSon( oSon:nID )

 // Deinitialize Hash
 EndMyHash()

RETURN NIL


CLASS MyFather


 DATA nID

       METHOD New()
       METHOD Event()
       METHOD Link()
       METHOD MsgShow()

ENDCLASS

METHOD New() CLASS MyFather

 ::nID := 1

RETURN Self

METHOD Link() CLASS MyFather

 // Call to LINKFROMC
 LinkFromC( Self, ::nID )

RETURN NIL

METHOD Event( nMsg ) CLASS MyFather

  ::MsgShow()

RETURN NIL

METHOD MsgShow( ) CLASS MyFather

       //LogFile( "X.log", { "Message from Father" } )
       ? "Message from Father"

RETURN NIL


CLASS MySon FROM MyFather
       METHOD New()
       METHOD Event()
       METHOD MyMsg()
ENDCLASS

METHOD New() CLASS MySon

 ::nID := 2

RETURN Self

METHOD Event()

 ::MyMsg()

RETURN Super:HandleEvent()

METHOD MyMsg()

 //LogFile( "X.log", { "Message from Son" } )
 ? "Message from Son"

RETURN NIL
------------- END PRG ------------


------------- 'C' ----------------
#include <hbapi.h>
#include <hbstack.h>
#include <hbapicls.h>
#include <hbapifs.h>
#include <hbapiitm.h>
#include <hbvm.h>
#include <hbinit.h>
#include <windows.h>

static PHB_ITEM pMyHash = NULL;

 // FUNCTION FOR SAVE SELF TO MYHASH
 HB_FUNC( LINKFROMC )
 {
    PHB_ITEM pSelf = hb_param( 1, HB_IT_ANY );
    PHB_ITEM pKey  = hb_itemPutNL( hb_itemNew( NULL ), ( long ) hb_parnl( 2
) );
    hb_hashAdd( pMyHash, pKey, pSelf );
    hb_itemRelease( pKey );
 }

 HB_FUNC( INITMYHASH )
 {
               pMyHash = hb_hashNew( NULL );
 }

 HB_FUNC( ENDMYHASH )
 {
               hb_itemRelease( pMyHash );
 }

 HB_FUNC( GETMSGFROMSON )
 {
   PHB_ITEM pSelf = NULL;
   PHB_ITEM pID  = hb_itemPutNL( hb_itemNew( NULL ), ( long ) hb_parnl( 1 )
);
   LONG lMsg = 123;

   pSelf = hb_hashGetItemPtr( pMyHash, pID, HB_HASH_AUTOADD_ACCESS );

   hb_itemRelease( pID );

   hb_objSendMsg( pSelf,"EVENT", 1, ( long ) lMsg ); // HERE GPF

   /*  Using it: not GPF, but i'dont know if all working fine on VM
        hb_vmPushSymbol( hb_dynsymSymbol( hb_dynsymGetCase( "EVENT"
) ) );
       hb_vmPush( pSelf );
       hb_vmPushLong( (LONG ) lMsg );
       hb_vmDo( 1 );
   */
 }
------------- END 'C' ------------
_______________________________________________
Harbour mailing list
[email protected]
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to