fdo#74148: sfx2: fix crash when editing template

SfxTemplateManagerDlg::OnTemplateEdit() accesses invalid iterator
because during loadComponentFromURL() it happens that
ThumnailView::LoseFocus() is called and maSelTemplates is cleared.

Change-Id: I074a70e5ce8bc89a38b720ddd0325c69c1d2b9ff
(cherry picked from commit c8e206fdaab7490fb6e62bc7ab475888236179c2)
Reviewed-on: https://gerrit.libreoffice.org/7904
Reviewed-by: Fridrich Strba <fridrich@documentfoundation.org>
Tested-by: Fridrich Strba <fridrich@documentfoundation.org>