summaryrefslogtreecommitdiff
path: root/sw/source/uibase
diff options
context:
space:
mode:
authorJustin Luth <justin.luth@collabora.com>2023-05-03 19:03:49 -0400
committerJustin Luth <jluth@mail.com>2023-05-04 02:46:53 +0200
commit83b1f6b58a30bdb589e9ce73deef39f021aebde1 (patch)
treefc09a0cb2143cbd448e504ff6a8926eaa9f9a85f /sw/source/uibase
parenta55af69baefd7965da3a7faf5af1c049fe99f9b4 (diff)
tdf#86630 sw page number wizard: avoid crash when no GetCurrFrame
The steps to get the crash were: -create a header (and leave the cursor in the header) -use the wizard to create a non-mirrored footer I had seen this crash happening occassionally during development, but hadn't yet identified the exact steps to consistently reproduce. Thanks to QA who tracked that down. Although it looks/feels like a hack, it actually works amazingly well. The simple act of SetCursorInHdFt "fixes" GetCurrFrame/Get*PageNum, but we can't always use that because we don't know whether we are on an odd or even or first page when we start, so Goto*Text is the best when non-mirroring. Change-Id: I0e2f28d9c8fd2d1a10afede885b525c42ed08af4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151345 Tested-by: Jenkins Reviewed-by: Justin Luth <jluth@mail.com>
Diffstat (limited to 'sw/source/uibase')
-rw-r--r--sw/source/uibase/shells/textfld.cxx11
1 files changed, 7 insertions, 4 deletions
diff --git a/sw/source/uibase/shells/textfld.cxx b/sw/source/uibase/shells/textfld.cxx
index 63d0db3c0b37..d3b3d6853dff 100644
--- a/sw/source/uibase/shells/textfld.cxx
+++ b/sw/source/uibase/shells/textfld.cxx
@@ -1134,8 +1134,14 @@ FIELD_INSERT:
bool bInHF = false;
bool bSkipMirror = true;
size_t nEvenPage = 0;
- if (bCreateMirror)
+ if (bCreateMirror || !rSh.GetCurrFrame())
{
+ // Come here if Currframe can't be found, otherwise Goto*Text will crash.
+ // Get*PageNum will also be invalid (0), so we have no idea where we are.
+ // (Since not asking for mirror, the likelihood is that the bHeader is shared,
+ // in which case it doesn't matter anyway, and we just hope for the best.)
+ // Read the code in this block assuming that bCreateMirror is true.
+
// There are enough pages that there probably is a valid odd page.
// However, that is not guaranteed: perhaps the page style switched,
// or a blank page was forced, or some other complexity.
@@ -1173,9 +1179,6 @@ FIELD_INSERT:
}
else
{
- // CurrFrame is lost when mirror is created. Goto*Text crashes if no CurrFrame
- assert(rSh.GetCurrFrame()); // not guaranteed, but normally assumed
-
if (bHeader)
bInHF = rSh.GotoHeaderText();
else