gtktiledviewer: don't crash on opening non-existing files

Change-Id: Ic48adaf038e8fbcc86a94b5e351d2f963fcfcd16
This commit is contained in:
Miklos Vajna
2015-09-18 10:58:24 +02:00
parent de244205f2
commit 43b2103f93
2 changed files with 14 additions and 4 deletions

View File

@@ -554,8 +554,20 @@ static void openDocumentCallback (GObject* source_object, GAsyncResult* res, gpo
if (!lok_doc_view_open_document_finish(pDocView, res, &error))
{
g_warning ("Error occurred while opening the document : %s", error->message);
g_error_free (error);
GtkDialogFlags eFlags = GTK_DIALOG_DESTROY_WITH_PARENT;
GtkWidget* pDialog = gtk_message_dialog_new(GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(pDocView))),
eFlags,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_CLOSE,
"Error occurred while opening the document: '%s'",
error->message);
gtk_dialog_run(GTK_DIALOG(pDialog));
gtk_widget_destroy(pDialog);
g_error_free(error);
gtk_widget_destroy(GTK_WIDGET(pDocView));
gtk_main_quit();
return;
}
populatePartSelector(pDocView);

View File

@@ -1225,9 +1225,7 @@ openDocumentInThread (gpointer data)
priv->m_pDocument = priv->m_pOffice->pClass->documentLoad( priv->m_pOffice, priv->m_aDocPath );
if ( !priv->m_pDocument )
{
// FIXME: should have a GError parameter and populate it.
char *pError = priv->m_pOffice->pClass->getError( priv->m_pOffice );
fprintf( stderr, "Error opening document '%s'\n", pError );
g_task_return_new_error(task, 0, 0, "%s", pError);
}
else