Resolves: tdf#120487 postit losing focus triggering recreation of postit

Change-Id: Idde6b740bc94de62bbd528b656841ab37e3f3786
Reviewed-on: https://gerrit.libreoffice.org/61682
Tested-by: Jenkins
Reviewed-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com>
diff --git a/sw/source/uibase/docvw/PostItMgr.cxx b/sw/source/uibase/docvw/PostItMgr.cxx
index 2cd8d420..4565d48 100644
--- a/sw/source/uibase/docvw/PostItMgr.cxx
+++ b/sw/source/uibase/docvw/PostItMgr.cxx
@@ -309,8 +309,11 @@ void SwPostItMgr::RemoveItem( SfxBroadcaster* pBroadcast )
            SwSidebarItem* p = (*i);
            if (GetActiveSidebarWin() == p->pPostIt)
                SetActiveSidebarWin(nullptr);
            p->pPostIt.disposeAndClear();
            // tdf#120487 remove from list before dispose, so comment window
            // won't be recreated due to the entry still in the list if focus
            // transferring from the pPostIt triggers relayout of postits
            mvPostItFields.erase(i);
            p->pPostIt.disposeAndClear();
            delete p;
            break;
        }