diff options
author | Caolán McNamara <caolan.mcnamara@collabora.com> | 2024-09-07 20:21:06 +0100 |
---|---|---|
committer | Caolán McNamara <caolan.mcnamara@collabora.com> | 2024-09-09 09:17:13 +0200 |
commit | 1ff238e5703507ad9d60810d20817052e5b43390 (patch) | |
tree | 27d1798b71466005c7ff7590a4c42b10c0044011 /svx/source | |
parent | d9988b57b3acaf2541b4cf4bbf7c972f056b37e9 (diff) |
enforce null checking of AcquireTheme return
Change-Id: I184603be25be734ec377439622872406ef74898a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173026
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Diffstat (limited to 'svx/source')
-rw-r--r-- | svx/source/gallery2/galbrws1.cxx | 65 |
1 files changed, 34 insertions, 31 deletions
diff --git a/svx/source/gallery2/galbrws1.cxx b/svx/source/gallery2/galbrws1.cxx index e7e3cece147c..f1b1ece8a643 100644 --- a/svx/source/gallery2/galbrws1.cxx +++ b/svx/source/gallery2/galbrws1.cxx @@ -359,13 +359,14 @@ void GalleryBrowser1::ImplExecute(std::u16string_view rIdent) { if (rIdent == u"update") { - GalleryTheme* pTheme = mpGallery->AcquireTheme( GetSelectedTheme(), maLocalListener ); - - SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); - ScopedVclPtr<VclAbstractDialog> aActualizeProgress(pFact->CreateActualizeProgressDialog(mxThemes.get(), pTheme)); + if (GalleryTheme* pTheme = mpGallery->AcquireTheme( GetSelectedTheme(), maLocalListener )) + { + SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); + ScopedVclPtr<VclAbstractDialog> aActualizeProgress(pFact->CreateActualizeProgressDialog(mxThemes.get(), pTheme)); - aActualizeProgress->Execute(); - mpGallery->ReleaseTheme( pTheme, maLocalListener ); + aActualizeProgress->Execute(); + mpGallery->ReleaseTheme( pTheme, maLocalListener ); + } } else if (rIdent == u"delete") { @@ -376,45 +377,47 @@ void GalleryBrowser1::ImplExecute(std::u16string_view rIdent) } else if (rIdent == u"rename") { - GalleryTheme* pTheme = mpGallery->AcquireTheme( GetSelectedTheme(), maLocalListener ); - const OUString aOldName( pTheme->GetName() ); - - SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); - ScopedVclPtr<AbstractTitleDialog> aDlg(pFact->CreateTitleDialog(mxThemes.get(), aOldName)); - - if( aDlg->Execute() == RET_OK ) + if (GalleryTheme* pTheme = mpGallery->AcquireTheme(GetSelectedTheme(), maLocalListener)) { - const OUString aNewName( aDlg->GetTitle() ); + const OUString aOldName( pTheme->GetName() ); + + SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); + ScopedVclPtr<AbstractTitleDialog> aDlg(pFact->CreateTitleDialog(mxThemes.get(), aOldName)); - if( !aNewName.isEmpty() && ( aNewName != aOldName ) ) + if( aDlg->Execute() == RET_OK ) { - OUString aName( aNewName ); - sal_uInt16 nCount = 0; + const OUString aNewName( aDlg->GetTitle() ); - while( mpGallery->HasTheme( aName ) && ( nCount++ < 16000 ) ) + if( !aNewName.isEmpty() && ( aNewName != aOldName ) ) { - aName = aNewName + " " + OUString::number( nCount ); - } + OUString aName( aNewName ); + sal_uInt16 nCount = 0; - mpGallery->RenameTheme( aOldName, aName ); + while( mpGallery->HasTheme( aName ) && ( nCount++ < 16000 ) ) + { + aName = aNewName + " " + OUString::number( nCount ); + } + + mpGallery->RenameTheme( aOldName, aName ); + } } + mpGallery->ReleaseTheme( pTheme, maLocalListener ); } - mpGallery->ReleaseTheme( pTheme, maLocalListener ); } else if (rIdent == u"assign") { - GalleryTheme* pTheme = mpGallery->AcquireTheme( GetSelectedTheme(), maLocalListener ); - - if (pTheme && !pTheme->IsReadOnly()) + if (GalleryTheme* pTheme = mpGallery->AcquireTheme( GetSelectedTheme(), maLocalListener )) { + if (!pTheme->IsReadOnly()) + { + SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); + ScopedVclPtr<AbstractGalleryIdDialog> aDlg(pFact->CreateGalleryIdDialog(mxThemes.get(), pTheme)); + if( aDlg->Execute() == RET_OK ) + pTheme->SetId( aDlg->GetId(), true ); + } - SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); - ScopedVclPtr<AbstractGalleryIdDialog> aDlg(pFact->CreateGalleryIdDialog(mxThemes.get(), pTheme)); - if( aDlg->Execute() == RET_OK ) - pTheme->SetId( aDlg->GetId(), true ); + mpGallery->ReleaseTheme( pTheme, maLocalListener ); } - - mpGallery->ReleaseTheme( pTheme, maLocalListener ); } else if (rIdent == u"properties") { |