2022-10-17 19:17 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)

* include/hbvm.h
  * include/harbour.hbx
  * src/harbour.def
  * src/vm/hvm.c
    + added new C function:
         extern HB_EXPORT HB_BOOL hb_vmSetKeyPool( HB_BOOL fEnable );
      It allows to disable keyboard pooling by GT driver in main HVM loop.
      It's important in programs which mix GT terminal with GUI library
      which use common event loop. Many GUI objects are not reentrant
      safe and activating event loop during big changes may cause crash.
      Such things can happen in applications which try to mix HBQT
      and GTQTC. To avoid such problems before PRG code is called it's
      enough to disable keyboard pooling in main HVM loop, eg.
         if( hb_vmRequestReenter() )
         {
            HB_BOOL fKeyPool = hb_vmSetKeyPool( HB_FALSE );
            hb_vmPushEvalSym();
            hb_vmPush( pBlockItm );
            hb_vmSend( 0 );
            hb_vmSetKeyPool( fKeyPool );
            hb_vmRequestRestore();
         }
    + added new PRG function:
         __vmKeyPool( [<fEnable>] ) -> <fPrevState>
      It's PRG interface to above C function. If application uses GT driver
      and GUI library using the same event loop and such GUI library does not
      disable keyboard pooling in main HVM loop before PRG code is activated
      then it's enough to call this function at the beginning of application,
      eg.
         PROCEDURE INIT Clip()
            __vmKeyPool( .f. )
         RETURN
      With above peace of code you can mix HBQT or other QT wrapper with GTQTC.
This commit is contained in:
Przemysław Czerpak
2022-10-17 19:17:26 +02:00
parent 908527cc87
commit a68eec838f
5 changed files with 82 additions and 9 deletions

View File

@@ -1605,6 +1605,7 @@ DYNAMIC __TypeFile
DYNAMIC __vmCountThreads
DYNAMIC __vmItemID
DYNAMIC __vmItemRefs
DYNAMIC __vmKeyPool
DYNAMIC __vmModulesVerify
DYNAMIC __vmNoInternals
DYNAMIC __Wait

View File

@@ -130,6 +130,8 @@ extern HB_EXPORT HB_BOOL hb_vmTryEval( PHB_ITEM * pResult, PHB_ITEM pItem, HB_
extern HB_EXPORT HB_BOOL hb_vmIsActive( void );
extern HB_EXPORT HB_BOOL hb_vmIsReady( void );
extern HB_EXPORT HB_BOOL hb_vmSetKeyPool( HB_BOOL fEnable );
/* Return values of hb_vmRequestQuery() */
#define HB_QUIT_REQUESTED 1 /* immediately quit the application */
#define HB_BREAK_REQUESTED 2 /* break to nearest RECOVER/END sequence */