@@ -4826,101 +4826,55 @@ void CMainFrame::OnIdle(wxIdleEvent& event)
4826
4826
wxDateTime dt1 = wxDateTime::Now(),
4827
4827
dt2 = wxDateTime::UNow();
4828
4828
#endif
4829
- // BEW 11Jun22, test for advancement of the phrasebox; first time, oldSN will be -1, and curSN will be
4830
- // a valid sequ num, for box location; but the two being unequal gives a correct bHasAdvanced value.
4831
- // After that, oldSN will be set, and curSN will be at the later location - next pile or further on
4832
- // wherever a hole stops the box, and the test for equality will fail, and so an extra idleEvent will
4833
- // get requested below. But when the user has typed a new adaptation and hits Enter key, OnePass()
4834
- // will get that new value into the entry table of kbserver in a new row, as wxExecute() will have
4835
- // been called. The requested extra idleEvent will cause an immediate re-entry to line 4791 above,
4836
- // and we don't want that reentry to initiate a bogus (2nd) StoreText() done with the existing contents
4837
- // of the create_entry.dat file. So we have to do the following at this reentry situation:
4838
- // (a) compare oldSN and curSN - they will be identical because no advancement of the box has had
4839
- // a chance to happen. So that sets bHasAdvanced to FALSE.
4840
- // (b) the FALSE value for bHasAdvanced can then be used to do:
4841
- // (i) Skip over the OnePass() call, and
4842
- // (ii) Skip over the request for an extra idleEvent - thereby killing the re-entrance issue
4843
- // (iii) Halting the sequence of auto-insertions, thereby giving the user the opportunity to
4844
- // type something at the next hole, and, in CallExecute() for do_create_entry.py or .exe, allows the
4845
- // program counter to progress in the normal way, to complete the create_entry block of the switch
4846
- //
4847
- // BEW 3Aug22 added support to prevent call of OnePass() when the phrasebox is in a fixed location
4848
- // temporarily because a kbserver function (in CallExecute()) is being called and which does not
4849
- // involve relocating the phrasebox to some other location. The need for this was because
4850
- // do_pseudo_undelete.py was causing a bogus duplicate entry to be created in the entry table
4851
- // because OnIdle() fired and, without a test to make it's call of OnePass() be skipped, a duplicate
4852
- // entry resulted. Hmm, this logic addition blocks Enter from allowing movement forward - so too
4853
- // strong. Remove
4854
- //bool bStationaryBox = StationaryPhraseBox();
4855
4829
4856
4830
// These next lines apply for the comments above prior to the 3Aug22 addition
4857
- bool bHasAdvanced = TRUE; // initialise
4831
+ // bool bHasAdvanced = TRUE; // initialise BEW commented out at Bill's suggestion, email 19Mar24 12:02pm
4858
4832
int oldSN = pApp->m_nOldSequNum;
4859
4833
int curSN = pApp->m_nActiveSequNum;
4860
- // whm 5Oct2023 Note: The following test is still too weak for proper operation of the
4861
- // phrasebox. For example, when an operation like "Remove A Retranslation" has just
4862
- // completed, the phrasebox may not have advanced from its position and oldSN and currSN
4863
- // may still be the same making bHasAdvanced FALSE, and if so, the user cannot advance
4864
- // the phrasebox by pressing Enter.
4865
- // IMO here in the OnIdle() handler is not a good place to try to make such as restriction
4866
- // against the OnePass() function getting executed whenever >m_bAutoInsert is TRUE.
4867
- // As a temporary solution, I'm inicluding the if (gpApp->m_bIsKBServerProject || gpApp->m_bIsGlossingKBServerProject)
4868
- // tests along with the curSN == oldSN test below to prevent the code here from interferring
4869
- // with the Enter key press functionality.
4870
- //if (curSN == oldSN)
4871
- if (curSN == oldSN && (gpApp->m_bIsKBServerProject || gpApp->m_bIsGlossingKBServerProject))
4872
- {
4873
- bHasAdvanced = FALSE;
4874
- }
4875
- #if defined (_DEBUG)
4876
- wxLogDebug(_T("OnIdle() line %d, oldSN = %d , curSN = %d, bHasAdvanced = %d\n"), __LINE__,
4877
- oldSN, curSN, (int)bHasAdvanced);
4878
- #endif
4879
- // Testing do_create_entry.py or .exe by running the app (in _DEBUG mode) resulted in a re-entrancy
4880
- // loop which, if not stopped, would cause and infinite loop of calls of OnePass() until the
4881
- // app crashes due to stack overflow. So I've prevented this using oldSN and curSN as above
4882
- //if ((bHasAdvanced == TRUE) && !bStationaryBox)
4883
- if (bHasAdvanced == TRUE)
4884
- {
4885
- CAdapt_ItApp* pApp = &wxGetApp(); pApp = pApp; // avoid warning in Release mode
4886
- CSourcePhrase* pSrcPhrase = NULL; pSrcPhrase = pSrcPhrase; // avoid warning in Release mode
4834
+
4835
+ bool bIsKBSvrAdaptProj = gpApp->m_bIsKBServerProject;
4836
+ bool bIsKBSvGlossProj = gpApp->m_bIsGlossingKBServerProject;
4837
+
4838
+ // BEW 19Mar24 removed the constraining test here, which uses bHasAdvanced, at Bill's request
4839
+ // and to retest to see if reentrancy problems arise from the today's changes
4840
+ CAdapt_ItApp* pApp = &wxGetApp(); pApp = pApp; // avoid warning in Release mode
4841
+ CSourcePhrase* pSrcPhrase = NULL; pSrcPhrase = pSrcPhrase; // avoid warning in Release mode
4887
4842
#if defined(_DEBUG) //&& defined(FLAGS)
4888
- {
4889
- if (pApp->m_pActivePile != NULL)
4843
+ {
4844
+ if (pApp->m_pActivePile != NULL)
4845
+ {
4846
+ pSrcPhrase = pApp->m_pActivePile->GetSrcPhrase();
4847
+ if (pSrcPhrase->m_nSequNumber >= 12)
4890
4848
{
4891
- pSrcPhrase = pApp->m_pActivePile->GetSrcPhrase();
4892
- if (pSrcPhrase->m_nSequNumber >= 12)
4893
- {
4894
- wxLogDebug(_T("\nOnIdle(), line %d, sn=%d, m_key= %s, m_bAbandonable %d, m_bRetainBoxContents %d, m_bUserTypedSomething %d, bHasAdvanced= [%d], m_bAutoInsert %d OnePass() NEXT"),
4895
- __LINE__, pSrcPhrase->m_nSequNumber, pSrcPhrase->m_key.c_str(), (int)pApp->m_pTargetBox->m_bAbandonable, (int)pApp->m_pTargetBox->m_bRetainBoxContents,
4896
- (int)pApp->m_bUserTypedSomething, (int)bHasAdvanced, (int)pApp->m_bAutoInsert);
4897
- }
4849
+ wxLogDebug(_T("\nOnIdle(), line %d, sn=%d, m_key= %s, m_bAbandonable %d, m_bRetainBoxContents %d, m_bUserTypedSomething %d, m_bAutoInsert %d, bIsKBSvrAdaptProj %d, bIsKBSvGlossProj %d, OnePass() NEXT"),
4850
+ __LINE__, pSrcPhrase->m_nSequNumber, pSrcPhrase->m_key.c_str(), (int)pApp->m_pTargetBox->m_bAbandonable, (int)pApp->m_pTargetBox->m_bRetainBoxContents,
4851
+ (int)pApp->m_bUserTypedSomething, (int)pApp->m_bAutoInsert, (int)bIsKBSvrAdaptProj, (int)bIsKBSvGlossProj);
4898
4852
}
4899
4853
}
4854
+ }
4900
4855
#endif
4901
- // Do the call, but skip this block if the phrasebox has not advanced
4902
- bSuccessfulInsertAndMove = pBox->OnePass(pView); // whm note: This is
4856
+ // Do the call, but skip this block if the phrasebox has not advanced
4857
+ bSuccessfulInsertAndMove = pBox->OnePass(pView); // whm note: This is
4903
4858
// the only place OnePass() is called
4904
4859
#if defined (_DEBUG)
4905
- if (bSuccessfulInsertAndMove)
4860
+ if (bSuccessfulInsertAndMove)
4861
+ {
4862
+ pSrcPhrase = pApp->m_pActivePile->GetSrcPhrase();
4863
+ if (pSrcPhrase->m_nSequNumber >= 12)
4906
4864
{
4907
- pSrcPhrase = pApp->m_pActivePile->GetSrcPhrase();
4908
- if (pSrcPhrase->m_nSequNumber >= 12)
4909
- {
4910
- wxLogDebug(_T("%s::%s(), line %d, sn=%d, m_key= [%s], m_targetStr= [%s], m_bAutoInsert %d OnePass() JUST HAPPENED"),
4911
- __FILE__, __FUNCTION__, __LINE__, pSrcPhrase->m_nSequNumber, pSrcPhrase->m_key.c_str(), pSrcPhrase->m_targetStr.c_str(),
4912
- (int)pApp->m_bAutoInsert);
4913
- }
4865
+ wxLogDebug(_T("OnIdle(), line %d, sn=%d, m_key= [%s], m_targetStr= [%s], m_bAutoInsert %d, bIsKBSvrAdaptProj %d, bIsKBSvGlossProj %d, OnePass() JUST HAPPENED"),
4866
+ __LINE__, pSrcPhrase->m_nSequNumber, pSrcPhrase->m_key.c_str(), pSrcPhrase->m_targetStr.c_str(),
4867
+ (int)pApp->m_bAutoInsert, (int)pApp->m_bAutoInsert, (int)bIsKBSvrAdaptProj, (int)bIsKBSvGlossProj);
4914
4868
}
4915
- #endif
4916
4869
}
4870
+ #endif
4917
4871
4918
4872
// don't slow things down unless we need to investigate
4919
4873
#ifdef SHOW_ONEPASS_BENCHMARKS
4920
- dt1 = dt2;
4921
- dt2 = wxDateTime::UNow();
4922
- wxLogDebug(_T("********In OnIdle() OnePass() executed in %s ms"),
4923
- (dt2 - dt1).Format(_T("%l")).c_str());
4874
+ dt1 = dt2;
4875
+ dt2 = wxDateTime::UNow();
4876
+ wxLogDebug(_T("********In OnIdle() OnePass() executed in %s ms"),
4877
+ (dt2 - dt1).Format(_T("%l")).c_str());
4924
4878
#endif
4925
4879
4926
4880
// whm added 20Nov10 reset the m_bIsGuess flag below. Can't do it in PlaceBox()
@@ -4930,53 +4884,16 @@ void CMainFrame::OnIdle(wxIdleEvent& event)
4930
4884
pApp->m_bIsGuess = FALSE;
4931
4885
if (bSuccessfulInsertAndMove)
4932
4886
{
4933
- // enable next iteration, but not when so-enabling would result in an infinite loop of reentrancy
4934
- if (bHasAdvanced)
4935
- {
4936
- // If StoreText has done a CallExecute() for the create_entry enum block, then
4937
- // the user must have made a new translation - which can only be done while the
4938
- // phrasebox was halted, and in that circumstance, immediately requesting a new
4939
- // idleEvent be posted, as here, would cause immediate re-entrancy and calling
4940
- // of OnPass() again wrongly, which would lead to an unending loop until the
4941
- // app crashs due to stack overflow. Disallowing RequestMore() when the box
4942
- // has not advanced, kills the reentrancy problem
4943
4887
event.RequestMore(); // Bill added
4944
- }
4945
- else
4946
- {
4947
- // BEW 11Jun22, the phrasebox has not advanced, so bring the
4948
- // box to a halt, but continue to enable OnIdle calls
4949
- pApp->m_bAutoInsert = FALSE;
4950
- }
4951
4888
}
4952
4889
else
4953
4890
{
4954
- // halt iterations, we did not make a match or could not move forward,
4891
+ // halt iterations, we did not succeed or could not move forward,
4955
4892
// but continue to enable OnIdle calls
4956
4893
pApp->m_bAutoInsert = FALSE;
4894
+ event.RequestMore(); // BEW added, 19Mar24
4957
4895
}
4958
4896
4959
- // BEW 28/jul23, when moving forward to pNewPile returns NULL, we've probably reached
4960
- // unexpected doc end, so perhaps returning here when bSuccessfulInsertAndMove is
4961
- // FALSE might be helpful - as the calls further down will certainly fail in this circumstance
4962
- // ? No, I'm scared, maybe the bool can be false for other scenarios which don't destroy the app, I'll comment it out for a few levels
4963
- //if (!bSuccessfulInsertAndMove)
4964
- //{
4965
- // return;
4966
- //}
4967
- /* #if defined(_DEBUG) && defined(FLAGS)
4968
- {
4969
- CAdapt_ItApp* pApp = &wxGetApp();
4970
- CSourcePhrase* pSrcPhrase = NULL;
4971
- if (pApp->m_pActivePile != NULL)
4972
- {
4973
- pSrcPhrase = pApp->m_pActivePile->GetSrcPhrase();
4974
- wxLogDebug(_T("\n%s::%s(), line %d, sn=%d, m_key= %s, m_bAbandonable %d, m_bRetainBoxContents %d, m_bUserTypedSomething %d, m_bBoxTextByCopyOnly %d, m_bAutoInsert %d"),
4975
- __FILE__, __FUNCTION__, __LINE__, pSrcPhrase->m_nSequNumber, pSrcPhrase->m_key.c_str(), (int)pApp->m_pTargetBox->m_bAbandonable, (int)pApp->m_pTargetBox->m_bRetainBoxContents,
4976
- (int)pApp->m_bUserTypedSomething, (int)pApp->m_pTargetBox->m_bBoxTextByCopyOnly, (int)pApp->m_bAutoInsert);
4977
- }
4978
- }
4979
- #endif */
4980
4897
} // end of TRUE block for test: if (pApp->m_bAutoInsert)
4981
4898
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
4982
4899
// whm added 10Jan2018 to support quick selection of a translation equivalent.
@@ -5055,7 +4972,6 @@ void CMainFrame::OnIdle(wxIdleEvent& event)
5055
4972
//#endif
5056
4973
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
5057
4974
5058
-
5059
4975
// BEW 2Dec2014 Alan Buseman's Guesser - support for hiding the GuesserUpdate() calls
5060
4976
// which need to be done pretty often -- and which block the GUI whether done synchronously
5061
4977
// as is done here, or asynchronously on a thread (due to mutexes blocking KB saves and
0 commit comments