From e7d508f5a2e7dcdf082d23d1572d06227c255611 Mon Sep 17 00:00:00 2001 From: pngbill Date: Fri, 7 Jun 2024 16:23:09 -0500 Subject: [PATCH] Fixed issue of bad array index being sent to a filter status array when DoUsfmFilterChanges() is called at the end of the project page of the wizard and no document is yet open. --- source/Adapt_It.cpp | 25 +++++++++++++++++++++++++ source/Adapt_It.h | 7 ------- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/source/Adapt_It.cpp b/source/Adapt_It.cpp index ffa5265af..7bcc95145 100644 --- a/source/Adapt_It.cpp +++ b/source/Adapt_It.cpp @@ -35345,6 +35345,7 @@ enum Reparse reparseDoc) countBeforeEdit = countBeforeEdit; // avoid warning countAfterEdit = countAfterEdit; // avoid warning + /* // whm 29Feb204 added. We need to determine the filter status of the \x and \xt markers // before the edit in the filter page, so we can use this information to adjust the // filter status of the \xt marker properly after the filtering changes have been done @@ -35360,6 +35361,7 @@ enum Reparse reparseDoc) m_bMkr_xt_WasUnfilteredBeforeFilteringChange = !m_bMkr_xt_WasFilteredBeforeFilteringChange; //m_bMkr_x_WasFilteredBeforeFilteringChange = (bool)pUsfmFilterPageCommon->m_filterFlagsDocBeforeEdit.Item(indexOfXmarker); //m_bMkr_x_WasUnfilteredBeforeFilteringChange = !m_bMkr_x_WasFilteredBeforeFilteringChange; + */ int numFlags = (int)pUsfmFilterPageCommon->m_filterFlagsDoc.GetCount(); // The usfm filter page's m_SfmMarkerAndDescriptionsDoc wxStringArray and the parallel @@ -35436,6 +35438,29 @@ enum Reparse reparseDoc) if (bFilterChangeInDoc) { + // whm 7Jun2024 made the following booleans local to this block. + // These are designed to track the filter status of the \xt marker + // as it existed before a filtering session change using the filter + // page in Preferences. + bool m_bMkr_xt_WasFilteredBeforeFilteringChange; + bool m_bMkr_xt_WasUnfilteredBeforeFilteringChange; + + // whm 29Feb204 added. We need to determine the filter status of the \x and \xt markers + // before the edit in the filter page, so we can use this information to adjust the + // filter status of the \xt marker properly after the filtering changes have been done + // by the TokenizeText() call below. + wxString xMkr = _T("\\x "); + wxString xtMkr = _T("\\xt "); + int indexOfXTmarker; + //int indexOfXmarker; + indexOfXTmarker = FindArrayStringUsingSubString(xtMkr, pUsfmFilterPageCommon->pSfmMarkerAndDescriptionsDoc, 0); + //indexOfXmarker = FindArrayStringUsingSubString(xMkr, pUsfmFilterPageCommon->pSfmMarkerAndDescriptionsDoc, 0); + //wxUnusedVar(indexOfXmarker); + m_bMkr_xt_WasFilteredBeforeFilteringChange = (bool)pUsfmFilterPageCommon->m_filterFlagsDocBeforeEdit.Item(indexOfXTmarker); + m_bMkr_xt_WasUnfilteredBeforeFilteringChange = !m_bMkr_xt_WasFilteredBeforeFilteringChange; + //m_bMkr_x_WasFilteredBeforeFilteringChange = (bool)pUsfmFilterPageCommon->m_filterFlagsDocBeforeEdit.Item(indexOfXmarker); + //m_bMkr_x_WasUnfilteredBeforeFilteringChange = !m_bMkr_x_WasFilteredBeforeFilteringChange; + // Any filter change in the Doc requires updating the current USFM and Filtering data // structures. diff --git a/source/Adapt_It.h b/source/Adapt_It.h index e5a698bf3..82be0facc 100644 --- a/source/Adapt_It.h +++ b/source/Adapt_It.h @@ -5036,13 +5036,6 @@ class CAdapt_ItApp : public wxApp // whm 26Feb2024 the following m_bUnfiltering_ex_NotFiltered is set FALSE, but never used in code, so is now removed //bool m_bUnfiltering_ex_NotFiltered; //BEW 18Apr20, TRUE when unfiltered filtered \ex ... \ex* - // whm 29Feb2024 added the following booleans to track the status of the \x and \xt marker before - // a filtering session using the filter page in Preferences. - //bool m_bMkr_x_WasFilteredBeforeFilteringChange; - bool m_bMkr_xt_WasFilteredBeforeFilteringChange; - //bool m_bMkr_x_WasUnfilteredBeforeFilteringChange; - bool m_bMkr_xt_WasUnfilteredBeforeFilteringChange; - wxString m_chapterVerseAttrSpan; // BEW 18Apr20, store nearest earlier ch:vs ref for error message // whm 22Feb2024 moved the following two here to the App from the Doc, and renaming them m_...