diff options
author | Michael Meeks <michael.meeks@collabora.com> | 2014-06-26 11:14:50 +0100 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2014-06-27 08:56:42 +0100 |
commit | 3c440aad56cdaf3e0c05af6c7967a3d15b183034 (patch) | |
tree | d44698e22e795b6a8250844c8156829987597437 /libreofficekit | |
parent | c6bd06cb6dfa755dfb953329c8eeaa1f4c11fc1b (diff) |
LOK DocView: handle document load failure without crashing.
Change-Id: Icd668b3a7ec3ac58322a6af3f1da6008837d0b6b
Diffstat (limited to 'libreofficekit')
-rw-r--r-- | libreofficekit/source/gtk/lokdocview.c | 22 |
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 ) |