summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2014-06-26 11:14:50 +0100
committerAndrzej Hunt <andrzej.hunt@collabora.com>2014-07-01 09:20:05 +0200
commit8b532c3b0c6d57d740ccac7a06f7987c3d5a54da (patch)
tree24a814987f396e134a420297966681705befc9f6
parent60f23b885ad86b7f5260f32999aaa260aa1e4bbe (diff)
LOK DocView: handle document load failure without crashing.
Change-Id: Icd668b3a7ec3ac58322a6af3f1da6008837d0b6b (cherry picked from commit 3c440aad56cdaf3e0c05af6c7967a3d15b183034)
-rw-r--r--libreofficekit/source/gtk/lokdocview.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/libreofficekit/source/gtk/lokdocview.c b/libreofficekit/source/gtk/lokdocview.c
index 49aaf2e941b3..f813e6894eac 100644
--- a/libreofficekit/source/gtk/lokdocview.c
+++ b/libreofficekit/source/gtk/lokdocview.c
@@ -22,8 +22,9 @@ static void lok_docview_init( LOKDocView* pDocView );
void lcl_onDestroy( LOKDocView* pDocView, gpointer pData )
{
(void) pData;
- pDocView->pDocument->pClass->destroy( pDocView->pDocument );
- pDocView->pDocument = 0;
+ if ( pDocView->pDocument )
+ pDocView->pDocument->pClass->destroy( pDocView->pDocument );
+ pDocView->pDocument = NULL;
}
SAL_DLLPUBLIC_EXPORT guint lok_docview_get_type()
@@ -139,15 +140,22 @@ SAL_DLLPUBLIC_EXPORT gboolean lok_docview_open_document( LOKDocView* pDocView, c
if ( pDocView->pDocument )
{
pDocView->pDocument->pClass->destroy( pDocView->pDocument );
- pDocView->pDocument = 0;
+ pDocView->pDocument = NULL;
}
pDocView->pDocument = pDocView->pOffice->pClass->documentLoad( pDocView->pOffice,
- pPath );
-
- renderDocument( pDocView );
+ pPath );
+ if ( !pDocView->pDocument )
+ {
+ // FIXME: should have a GError parameter and populate it.
+ char *pError = pDocView->pOffice->pClass->getError( pDocView->pOffice );
+ fprintf( stderr, "Error opening document '%s'\n", pError );
+ return FALSE;
+ }
+ else
+ renderDocument( pDocView );
- return FALSE;
+ return TRUE;
}
SAL_DLLPUBLIC_EXPORT void lok_docview_set_zoom ( LOKDocView* pDocView, float fZoom )