diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-06-07 13:03:58 +0200 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2018-06-08 01:29:32 +0200 |
commit | 5708534b942c1d0ce384f6a8473da6bb569410e7 (patch) | |
tree | 2ec4fe87624541c15bf89c8b839e8f8dba8a89f4 /dbaccess | |
parent | 1e55a47e89a9d9d6cf9cb3993484022aaf2c097b (diff) |
look for unnecessary calls to Reference::is() after an UNO_QUERY_THROW
Since the previous call would throw if there was nothing to be assigned
to the value.
Idea from tml.
Used the following script to find places:
git grep -A3 -n UNO_QUERY_THROW | grep -B3 -F 'is()'
Change-Id: I36ba7b00bcd014bdf16c0455ab91056f82194969
Reviewed-on: https://gerrit.libreoffice.org/55417
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'dbaccess')
-rw-r--r-- | dbaccess/qa/extras/dialog-save.cxx | 9 | ||||
-rw-r--r-- | dbaccess/qa/extras/empty-stdlib-save.cxx | 9 | ||||
-rw-r--r-- | dbaccess/qa/extras/nolib-save.cxx | 9 | ||||
-rw-r--r-- | dbaccess/source/ui/misc/databaseobjectview.cxx | 13 | ||||
-rw-r--r-- | dbaccess/source/ui/tabledesign/TableController.cxx | 1 |
5 files changed, 3 insertions, 38 deletions
diff --git a/dbaccess/qa/extras/dialog-save.cxx b/dbaccess/qa/extras/dialog-save.cxx index e9194a0e6e7d..eb1095fe4ba7 100644 --- a/dbaccess/qa/extras/dialog-save.cxx +++ b/dbaccess/qa/extras/dialog-save.cxx @@ -72,17 +72,13 @@ void DialogSaveTest::test() uno::Reference< lang::XComponent > xComponent = loadFromDesktop(aFileName); CPPUNIT_ASSERT(xComponent.is()); uno::Reference< frame::XStorable > xDocStorable(xComponent, UNO_QUERY_THROW); - CPPUNIT_ASSERT(xDocStorable.is()); uno::Reference< document::XEmbeddedScripts > xDocScr(xComponent, UNO_QUERY_THROW); - CPPUNIT_ASSERT(xDocScr.is()); uno::Reference< script::XStorageBasedLibraryContainer > xStorBasLib(xDocScr->getBasicLibraries()); CPPUNIT_ASSERT(xStorBasLib.is()); uno::Reference< script::XLibraryContainer > xBasLib(xStorBasLib, UNO_QUERY_THROW); - CPPUNIT_ASSERT(xBasLib.is()); uno::Reference< script::XStorageBasedLibraryContainer > xStorDlgLib(xDocScr->getDialogLibraries()); CPPUNIT_ASSERT(xStorDlgLib.is()); uno::Reference< script::XLibraryContainer > xDlgLib(xStorDlgLib, UNO_QUERY_THROW); - CPPUNIT_ASSERT(xDlgLib.is()); xBasLib->loadLibrary(sStandard); CPPUNIT_ASSERT(xBasLib->isLibraryLoaded(sStandard)); // the whole point of this test is to test the "save" operation @@ -91,12 +87,10 @@ void DialogSaveTest::test() // make some change to enable a save // uno::Reference< document::XDocumentPropertiesSupplier > xDocPropSuppl(xComponent, UNO_QUERY_THROW); - // CPPUNIT_ASSERT(xDocPropSuppl.is()); // uno::Reference< document::XDocumentPropertiesSupplier > xDocProps(xDocPropSuppl->getDocumentProperties()); // CPPUNIT_ASSERT(xDocProps.is()); // xDocProps.setTitle(xDocProps.getTitle() + " suffix"); uno::Reference< util::XModifiable > xDocMod(xComponent, UNO_QUERY_THROW); - CPPUNIT_ASSERT(xDocMod.is()); xDocMod->setModified(true); // now save; the code path to exercise in this test is the "store to same location" @@ -105,7 +99,6 @@ void DialogSaveTest::test() // close uno::Reference< util::XCloseable > xDocCloseable(xComponent, UNO_QUERY_THROW); - CPPUNIT_ASSERT(xDocCloseable.is()); xDocCloseable->close(false); // All our uno::References are (should?) be invalid now -> let them go out of scope @@ -114,9 +107,7 @@ void DialogSaveTest::test() uno::Sequence<uno::Any> args(1); args[0] <<= aFileName; Reference<container::XHierarchicalNameAccess> xHNA(getMultiServiceFactory()->createInstanceWithArguments("com.sun.star.packages.Package", args), UNO_QUERY_THROW); - CPPUNIT_ASSERT(xHNA.is()); Reference< beans::XPropertySet > xPS(xHNA->getByHierarchicalName("Dialogs/Standard/Dialog1.xml"), UNO_QUERY_THROW); - CPPUNIT_ASSERT(xPS.is()); sal_Int64 nSize = 0; CPPUNIT_ASSERT(xPS->getPropertyValue("Size") >>= nSize); CPPUNIT_ASSERT(nSize != 0); diff --git a/dbaccess/qa/extras/empty-stdlib-save.cxx b/dbaccess/qa/extras/empty-stdlib-save.cxx index 648ffb29a1ef..86f381cf8519 100644 --- a/dbaccess/qa/extras/empty-stdlib-save.cxx +++ b/dbaccess/qa/extras/empty-stdlib-save.cxx @@ -72,17 +72,13 @@ void DialogSaveTest::test() uno::Reference< lang::XComponent > xComponent = loadFromDesktop(aFileName); CPPUNIT_ASSERT(xComponent.is()); uno::Reference< frame::XStorable > xDocStorable(xComponent, UNO_QUERY_THROW); - CPPUNIT_ASSERT(xDocStorable.is()); uno::Reference< document::XEmbeddedScripts > xDocScr(xComponent, UNO_QUERY_THROW); - CPPUNIT_ASSERT(xDocScr.is()); uno::Reference< script::XStorageBasedLibraryContainer > xStorBasLib(xDocScr->getBasicLibraries()); CPPUNIT_ASSERT(xStorBasLib.is()); uno::Reference< script::XLibraryContainer > xBasLib(xStorBasLib, UNO_QUERY_THROW); - CPPUNIT_ASSERT(xBasLib.is()); uno::Reference< script::XStorageBasedLibraryContainer > xStorDlgLib(xDocScr->getDialogLibraries()); CPPUNIT_ASSERT(xStorDlgLib.is()); uno::Reference< script::XLibraryContainer > xDlgLib(xStorDlgLib, UNO_QUERY_THROW); - CPPUNIT_ASSERT(xDlgLib.is()); xBasLib->loadLibrary(sStandard); xDlgLib->loadLibrary(sStandard); CPPUNIT_ASSERT(xBasLib->isLibraryLoaded(sStandard)); @@ -102,15 +98,12 @@ void DialogSaveTest::test() xI->removeByName("Dialog1"); // uno::Reference< util::XModifiable > xDlgMod(xDlgLib, UNO_QUERY_THROW); - // CPPUNIT_ASSERT(xDlgMod.is()); // xDlgMod->setModified(sal_True); // uno::Reference< util::XModifiable > xScrMod(xDocScr, UNO_QUERY_THROW); - // CPPUNIT_ASSERT(xScrMod.is()); // xScrMod->setModified(sal_True); // uno::Reference< util::XModifiable > xDocMod(xComponent, UNO_QUERY_THROW); - // CPPUNIT_ASSERT(xDocMod.is()); // std::cerr << "** Modified: " << static_cast<bool>(xDocMod->isModified()) << std::endl; // xDocMod->setModified(sal_True); // std::cerr << "** Modified: " << static_cast<bool>(xDocMod->isModified()) << std::endl; @@ -122,7 +115,6 @@ void DialogSaveTest::test() // close uno::Reference< util::XCloseable > xDocCloseable(xComponent, UNO_QUERY_THROW); - CPPUNIT_ASSERT(xDocCloseable.is()); xDocCloseable->close(false); // All our uno::References are (should?) be invalid now -> let them go out of scope @@ -131,7 +123,6 @@ void DialogSaveTest::test() uno::Sequence<uno::Any> args(1); args[0] <<= aFileName; Reference<container::XHierarchicalNameAccess> xHNA(getMultiServiceFactory()->createInstanceWithArguments("com.sun.star.packages.Package", args), UNO_QUERY_THROW); - CPPUNIT_ASSERT(xHNA.is()); CPPUNIT_ASSERT(!xHNA->hasByHierarchicalName("Basic/Standard")); CPPUNIT_ASSERT(!xHNA->hasByHierarchicalName("Dialogs/Standard")); } diff --git a/dbaccess/qa/extras/nolib-save.cxx b/dbaccess/qa/extras/nolib-save.cxx index e42784c9800d..f5e4ae59b837 100644 --- a/dbaccess/qa/extras/nolib-save.cxx +++ b/dbaccess/qa/extras/nolib-save.cxx @@ -72,17 +72,13 @@ void DialogSaveTest::test() uno::Reference< lang::XComponent > xComponent = loadFromDesktop(aFileName); CPPUNIT_ASSERT(xComponent.is()); uno::Reference< frame::XStorable > xDocStorable(xComponent, UNO_QUERY_THROW); - CPPUNIT_ASSERT(xDocStorable.is()); uno::Reference< document::XEmbeddedScripts > xDocScr(xComponent, UNO_QUERY_THROW); - CPPUNIT_ASSERT(xDocScr.is()); uno::Reference< script::XStorageBasedLibraryContainer > xStorBasLib(xDocScr->getBasicLibraries()); CPPUNIT_ASSERT(xStorBasLib.is()); uno::Reference< script::XLibraryContainer > xBasLib(xStorBasLib, UNO_QUERY_THROW); - CPPUNIT_ASSERT(xBasLib.is()); uno::Reference< script::XStorageBasedLibraryContainer > xStorDlgLib(xDocScr->getDialogLibraries()); CPPUNIT_ASSERT(xStorDlgLib.is()); uno::Reference< script::XLibraryContainer > xDlgLib(xStorDlgLib, UNO_QUERY_THROW); - CPPUNIT_ASSERT(xDlgLib.is()); xBasLib->loadLibrary(sStandard); xDlgLib->loadLibrary(sStandard); CPPUNIT_ASSERT(xBasLib->isLibraryLoaded(sStandard)); @@ -92,15 +88,12 @@ void DialogSaveTest::test() xDlgLib->removeLibrary(sStandard); // uno::Reference< util::XModifiable > xDlgMod(xDlgLib, UNO_QUERY_THROW); - // CPPUNIT_ASSERT(xDlgMod.is()); // xDlgMod->setModified(sal_True); // uno::Reference< util::XModifiable > xScrMod(xDocScr, UNO_QUERY_THROW); - // CPPUNIT_ASSERT(xScrMod.is()); // xScrMod->setModified(sal_True); // uno::Reference< util::XModifiable > xDocMod(xComponent, UNO_QUERY_THROW); - // CPPUNIT_ASSERT(xDocMod.is()); // std::cerr << "** Modified: " << static_cast<bool>(xDocMod->isModified()) << std::endl; // xDocMod->setModified(sal_True); // std::cerr << "** Modified: " << static_cast<bool>(xDocMod->isModified()) << std::endl; @@ -112,7 +105,6 @@ void DialogSaveTest::test() // close uno::Reference< util::XCloseable > xDocCloseable(xComponent, UNO_QUERY_THROW); - CPPUNIT_ASSERT(xDocCloseable.is()); xDocCloseable->close(false); // All our uno::References are (should?) be invalid now -> let them go out of scope @@ -121,7 +113,6 @@ void DialogSaveTest::test() uno::Sequence<uno::Any> args(1); args[0] <<= aFileName; Reference<container::XHierarchicalNameAccess> xHNA(getMultiServiceFactory()->createInstanceWithArguments("com.sun.star.packages.Package", args), UNO_QUERY_THROW); - CPPUNIT_ASSERT(xHNA.is()); CPPUNIT_ASSERT(!xHNA->hasByHierarchicalName("Basic/Standard")); CPPUNIT_ASSERT(!xHNA->hasByHierarchicalName("Dialogs/Standard")); } diff --git a/dbaccess/source/ui/misc/databaseobjectview.cxx b/dbaccess/source/ui/misc/databaseobjectview.cxx index 676b26cbf92f..e68f17ffd3ca 100644 --- a/dbaccess/source/ui/misc/databaseobjectview.cxx +++ b/dbaccess/source/ui/misc/databaseobjectview.cxx @@ -232,16 +232,9 @@ namespace dbaui // try whether the designer is a dialog Reference< XExecutableDialog > xDialog( xDesigner, UNO_QUERY_THROW ); - if ( xDialog.is() ) - { - try { AsyncDialogExecutor::executeModalDialogAsync( xDialog ); } - catch( const Exception& ) { DBG_UNHANDLED_EXCEPTION("dbaccess"); } - return nullptr; - } - - Reference< XComponent > xDesignerComponent( xDesigner, UNO_QUERY ); - OSL_ENSURE( xDesignerComponent.is(), "TableDesigner::doCreateView: a designer which is no dialog and no component?" ); - return xDesignerComponent; + try { AsyncDialogExecutor::executeModalDialogAsync( xDialog ); } + catch( const Exception& ) { DBG_UNHANDLED_EXCEPTION("dbaccess"); } + return nullptr; } Reference< XInterface > TableDesigner::impl_getConnectionProvidedDesigner_nothrow( const OUString& _rTableName ) diff --git a/dbaccess/source/ui/tabledesign/TableController.cxx b/dbaccess/source/ui/tabledesign/TableController.cxx index 71c6e722fecc..51898df9ff0b 100644 --- a/dbaccess/source/ui/tabledesign/TableController.cxx +++ b/dbaccess/source/ui/tabledesign/TableController.cxx @@ -961,7 +961,6 @@ bool OTableController::checkColumns(bool _bNew) void OTableController::alterColumns() { Reference<XColumnsSupplier> xColSup(m_xTable,UNO_QUERY_THROW); - OSL_ENSURE(xColSup.is(),"What happen here?!"); Reference<XNameAccess> xColumns = xColSup->getColumns(); Reference<XIndexAccess> xIdxColumns(xColumns,UNO_QUERY_THROW); |