From 17aef6608214035de38516d2ebd89757382dfdf4 Mon Sep 17 00:00:00 2001 From: pjrm Date: Thu, 21 Jun 2007 09:05:40 +0000 Subject: [PATCH] Handle the case of gnome_vfs_init failing. (Fixes Debian bug http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=415640.) --- src/dialogs/export.cpp | 7 ++++++- src/extension/input.cpp | 11 +---------- src/extension/internal/svg.cpp | 4 ++-- src/ui/dialog/filedialog.cpp | 30 +++++++++++++++++++++--------- 4 files changed, 30 insertions(+), 22 deletions(-) diff --git a/src/dialogs/export.cpp b/src/dialogs/export.cpp index da5a8c541..441047a27 100644 --- a/src/dialogs/export.cpp +++ b/src/dialogs/export.cpp @@ -30,6 +30,9 @@ #include #include #include +#ifdef WITH_GNOME_VFS +# include // gnome_vfs_initialized +#endif #include #include "helper/unit-menu.h" @@ -1305,7 +1308,9 @@ sp_export_browse_clicked (GtkButton *button, gpointer userdata) NULL ); #ifdef WITH_GNOME_VFS - gtk_file_chooser_set_local_only(GTK_FILE_CHOOSER (fs), false); + if (gnome_vfs_initialized()) { + gtk_file_chooser_set_local_only(GTK_FILE_CHOOSER(fs), false); + } #endif fe = (GtkWidget *)g_object_get_data (G_OBJECT (dlg), "filename"); diff --git a/src/extension/input.cpp b/src/extension/input.cpp index 94b0f6ab4..e17c690aa 100644 --- a/src/extension/input.cpp +++ b/src/extension/input.cpp @@ -153,16 +153,7 @@ Input::open (const gchar *uri) } timer->touch(); - SPDocument * doc = NULL; - -#ifdef WITH_GNOME_VFS - doc = imp->open(this, uri); -#else - if (Inkscape::IO::file_test(uri, G_FILE_TEST_EXISTS)) { - doc = imp->open(this, uri); - } -#endif - + SPDocument *const doc = imp->open(this, uri); if (doc != NULL) { Inkscape::XML::Node * repr = sp_document_repr_root(doc); bool saved = sp_document_get_undo_sensitive(doc); diff --git a/src/extension/internal/svg.cpp b/src/extension/internal/svg.cpp index 5d7b38c33..33cbfe150 100644 --- a/src/extension/internal/svg.cpp +++ b/src/extension/internal/svg.cpp @@ -102,7 +102,7 @@ Svg::init(void) #ifdef WITH_GNOME_VFS #define BUF_SIZE 8192 -gchar * +static gchar * _load_uri (const gchar *uri) { GnomeVFSHandle *handle = NULL; @@ -148,7 +148,7 @@ SPDocument * Svg::open (Inkscape::Extension::Input *mod, const gchar *uri) { #ifdef WITH_GNOME_VFS - if (gnome_vfs_uri_is_local(gnome_vfs_uri_new(uri))) { + if (!gnome_vfs_initialized() || gnome_vfs_uri_is_local(gnome_vfs_uri_new(uri))) { // Use built-in loader instead of VFS for this return sp_document_new(uri, TRUE); } diff --git a/src/ui/dialog/filedialog.cpp b/src/ui/dialog/filedialog.cpp index b6c35140e..2a5ededbb 100644 --- a/src/ui/dialog/filedialog.cpp +++ b/src/ui/dialog/filedialog.cpp @@ -34,6 +34,9 @@ //Another hack #include #include +#ifdef WITH_GNOME_VFS +# include // gnome_vfs_initialized +#endif @@ -821,12 +824,14 @@ void FileDialogBase::_updatePreviewCallback() Glib::ustring fileName = get_preview_filename(); #ifdef WITH_GNOME_VFS - if (fileName.length() < 1) + if ( fileName.empty() && gnome_vfs_initialized() ) { fileName = get_preview_uri(); + } #endif - if (fileName.length() < 1) + if (fileName.empty()) { return; + } svgPreview.set(fileName, dialogType); } @@ -955,7 +960,9 @@ FileOpenDialogImpl::FileOpenDialogImpl(const Glib::ustring &dir, set_select_multiple(true); #ifdef WITH_GNOME_VFS - set_local_only(false); + if (gnome_vfs_initialized()) { + set_local_only(false); + } #endif /* Initalize to Autodetect */ @@ -1047,7 +1054,7 @@ FileOpenDialogImpl::show() } myFilename = get_filename(); #ifdef WITH_GNOME_VFS - if (myFilename.length() < 1) + if (myFilename.empty() && gnome_vfs_initialized()) myFilename = get_uri(); #endif cleanup( true ); @@ -1090,7 +1097,7 @@ std::vectorFileOpenDialogImpl::getFilenames() { std::vector result = get_filenames(); #ifdef WITH_GNOME_VFS - if (result.empty()) + if (result.empty() && gnome_vfs_initialized()) result = get_uris(); #endif return result; @@ -1311,7 +1318,9 @@ FileSaveDialogImpl::FileSaveDialogImpl(const Glib::ustring &dir, set_select_multiple(false); #ifdef WITH_GNOME_VFS - set_local_only(false); + if (gnome_vfs_initialized()) { + set_local_only(false); + } #endif /* Initalize to Autodetect */ @@ -1557,7 +1566,7 @@ void FileSaveDialogImpl::updateNameAndExtension() // Pick up any changes the user has typed in. Glib::ustring tmp = get_filename(); #ifdef WITH_GNOME_VFS - if ( tmp.empty() ) { + if ( tmp.empty() && gnome_vfs_initialized() ) { tmp = get_uri(); } #endif @@ -1932,7 +1941,9 @@ FileExportDialogImpl::FileExportDialogImpl(const Glib::ustring &dir, set_select_multiple(false); #ifdef WITH_GNOME_VFS - set_local_only(false); + if (gnome_vfs_initialized()) { + set_local_only(false); + } #endif /* Initalize to Autodetect */ @@ -2141,8 +2152,9 @@ FileExportDialogImpl::show() } myFilename = get_filename(); #ifdef WITH_GNOME_VFS - if (myFilename.length() < 1) + if ( myFilename.empty() && gnome_vfs_initialized() ) { myFilename = get_uri(); + } #endif /* -- 2.30.2