summaryrefslogtreecommitdiff
path: root/sc/source/ui/view/cellsh1.cxx
diff options
context:
space:
mode:
authorKohei Yoshida <kyoshida@novell.com>2011-06-10 13:06:49 -0400
committerKohei Yoshida <kyoshida@novell.com>2011-06-10 13:06:49 -0400
commit6f8ed557eb49c9e3543453de62ab8b02f9756a57 (patch)
treed14e664809bc19957aa0e485fdff9829598da93a /sc/source/ui/view/cellsh1.cxx
parentd23c699db8d2233fe1eb0b33948d55d9f9f53d82 (diff)
fdo#33137: Prevent crash on pivot table with invalid database connection.
Check for NULL cache state to handle invalid database connection more gracefully (i.e. without crashing).
Diffstat (limited to 'sc/source/ui/view/cellsh1.cxx')
-rw-r--r--sc/source/ui/view/cellsh1.cxx24
1 files changed, 23 insertions, 1 deletions
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index de1a010df5fd..78b56a169977 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -2127,6 +2127,27 @@ void ScCellShell::ExecuteExternalSource(
_rRequest.Ignore();
}
+namespace {
+
+bool isDPSourceValid(const ScDPObject& rDPObj)
+{
+ if (rDPObj.IsImportData())
+ {
+ // If the data type is database, check if the database is still valid.
+ const ScImportSourceDesc* pDesc = rDPObj.GetImportSourceDesc();
+ if (!pDesc)
+ return false;
+
+ const ScDPCache* pCache = pDesc->CreateCache();
+ if (!pCache)
+ // cashe creation failed, probably due to invalid connection.
+ return false;
+ }
+ return true;
+}
+
+}
+
void ScCellShell::ExecuteDataPilotDialog()
{
ScModule* pScMod = SC_MOD();
@@ -2142,7 +2163,8 @@ void ScCellShell::ExecuteDataPilotDialog()
pData->GetTabNo() );
if ( pDPObj ) // on an existing table?
{
- pNewDPObject.reset(new ScDPObject(*pDPObj));
+ if (isDPSourceValid(*pDPObj))
+ pNewDPObject.reset(new ScDPObject(*pDPObj));
}
else // create new table
{