Hi Przemek, >> These calls are missing from hbbmcdx, xhb, rddsql and rddads, >> maybe it'd be worth to check if they need it or not. I'm >> still rather unsure when to use it in practice. > > The classic example when they have to be executed are .prg > code object destructors. They can be activated at any moment > when some variables is cleared, i.e.: > hb_itemCopy( pItem, hb_stackReturnItem() ); > can activate destructor when clears pItem. If pItem destructor > does not save and restore hb_stackReturnItem() then before coping > the value inside hb_stackReturnItem() will be destroyed. > ... > I remember like few years ago xHarbour users suddenly began to > report problems with very strange in practice unrepeatable RTEs. > For few months such reports were ignored and finally someone > created a code example. After reducing it was sth like: > > proc main() > [SetWVTCallback()] > while true() ; enddo > func true() ; return .T. > ... > If you are still not sure when to use hb_vmRequestReenter()/ > hb_vmRequestRestore() then you can use this rule: > If you reeneter HVM from HB_FUNC() or local function which is > called from HB_FUNC() then you do not have to use it. The call > to HB_FUNC() should be already well wrapped so it's not necessary > to repeat the same job. But if you are creating public C functions > which can be called from external code and you do not know the exact > execution context then U suggest to always save and restore HVM state. > > I hope that now it's more clear.
Many thanks for your detailed explanation, I think I get it now. [ BTW we should start to collect such e-mails for future reference. ] A typical example is callbacks, so my last fix seems to be a valid one. Brgds, Viktor _______________________________________________ Harbour mailing list (attachment size limit: 40KB) [email protected] http://lists.harbour-project.org/mailman/listinfo/harbour
