tdf#119610 tdf#112634: Don't show broken connections - RevB
This changes LO 6.0 commit 75a881829f19439245cdb859fc16d59461992f79
to use a light-weight check to see if a database exists.
The previous way made a connection, which is extremely
expensive if there is a password, or if network traffic
needs to timeout, etc. And if there are multiple
registered databases like that...
Change-Id: I980cb6979cfc7cae8f1251f3459718192459aaee
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109242
Tested-by: Jenkins
Reviewed-by: Justin Luth <justin_luth@sil.org>
diff --git a/sw/source/uibase/dbui/dbtree.cxx b/sw/source/uibase/dbui/dbtree.cxx
index e47c7dc..9d1aa0f 100644
--- a/sw/source/uibase/dbui/dbtree.cxx
+++ b/sw/source/uibase/dbui/dbtree.cxx
@@ -157,8 +157,10 @@
OUString aImg(RID_BMP_DB);
for (const OUString& rDBName : std::as_const(aDBNames))
{
Reference<XConnection> xConnection = pImpl->GetConnection(rDBName);
if (xConnection.is())
// If this database has a password or a (missing) remote connection,
// then it might take a long time or spam for unnecessary credentials.
// Just check that it basically exists to weed out any broken/obsolete registrations.
if (SwDBManager::getDataSourceAsParent(Reference<sdbc::XConnection>(), rDBName).is())
{
m_xTreeView->insert(nullptr, -1, &rDBName, nullptr, nullptr, nullptr, true, m_xScratchIter.get());
m_xTreeView->set_image(*m_xScratchIter, aImg);