vcl button: Avoid a potential crash.

Change-Id: I09d0777ef51045054b8e3bc88aba9fb025e6f9ff
This commit is contained in:
Jan Holesovsky
2014-10-21 14:26:05 +02:00
parent 6e1c661823
commit 40043080bc

View File

@@ -2149,19 +2149,22 @@ Image VclBuilder::getCommandImage(const OUString& rCommand, bool bLarge,
uno::Reference<frame::XModel> xModel(xController->getModel()); uno::Reference<frame::XModel> xModel(xController->getModel());
uno::Reference<ui::XUIConfigurationManagerSupplier> xSupplier(xModel, uno::UNO_QUERY); uno::Reference<ui::XUIConfigurationManagerSupplier> xSupplier(xModel, uno::UNO_QUERY);
uno::Reference<ui::XUIConfigurationManager> xDocUICfgMgr(xSupplier->getUIConfigurationManager(), uno::UNO_QUERY); if (xSupplier.is())
uno::Reference<ui::XImageManager> xDocImgMgr(xDocUICfgMgr->getImageManager(), uno::UNO_QUERY); {
uno::Reference<ui::XUIConfigurationManager> xDocUICfgMgr(xSupplier->getUIConfigurationManager(), uno::UNO_QUERY);
uno::Reference<ui::XImageManager> xDocImgMgr(xDocUICfgMgr->getImageManager(), uno::UNO_QUERY);
uno::Sequence< uno::Reference<graphic::XGraphic> > aGraphicSeq; uno::Sequence< uno::Reference<graphic::XGraphic> > aGraphicSeq;
uno::Sequence<OUString> aImageCmdSeq(1); uno::Sequence<OUString> aImageCmdSeq(1);
aImageCmdSeq[0] = rCommand; aImageCmdSeq[0] = rCommand;
aGraphicSeq = xDocImgMgr->getImages( nImageType, aImageCmdSeq ); aGraphicSeq = xDocImgMgr->getImages( nImageType, aImageCmdSeq );
uno::Reference<graphic::XGraphic> xGraphic = aGraphicSeq[0]; uno::Reference<graphic::XGraphic> xGraphic = aGraphicSeq[0];
Image aImage(xGraphic); Image aImage(xGraphic);
if (!!aImage) if (!!aImage)
return aImage; return aImage;
}
} }
catch (uno::Exception&) catch (uno::Exception&)
{ {