[glom] Avoid Operation Not Supported warnings at startup.



commit 98e70ec884b50b30b6748fa6447cbd5baf1b2542
Author: Murray Cumming <murrayc murrayc com>
Date:   Mon Mar 29 16:16:00 2010 +0200

    Avoid Operation Not Supported warnings at startup.
    
    * glom/application.cc:
    * glom/bakery/app_withdoc.cc:
    * glom/libglom/connectionpool_backends/postgres_self.cc:
    * glom/libglom/connectionpool_backends/sqlite.cc:
    * glom/libglom/document/bakery/document.cc:
    * glom/libglom/utils.cc:
    * glom/xsl_utils.cc: Avoid creating a Gio::File() from an empty URI,
        avoiding useless stdout warnings at startup.

 ChangeLog                                          |   13 +++++++++++++
 glom/application.cc                                |    3 +++
 glom/bakery/app_withdoc.cc                         |    3 +++
 .../connectionpool_backends/postgres_self.cc       |    8 +++++++-
 glom/libglom/connectionpool_backends/sqlite.cc     |    9 ++++++++-
 glom/libglom/document/bakery/document.cc           |   11 ++++++++++-
 glom/libglom/utils.cc                              |    3 +++
 glom/xsl_utils.cc                                  |    3 +--
 8 files changed, 48 insertions(+), 5 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 5a36c10..e37f9d0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2010-03-29  Murray Cumming  <murrayc murrayc com>
+
+    Avoid Operation Not Supported warnings at startup.
+
+	* glom/application.cc:
+	* glom/bakery/app_withdoc.cc:
+	* glom/libglom/connectionpool_backends/postgres_self.cc:
+	* glom/libglom/connectionpool_backends/sqlite.cc:
+	* glom/libglom/document/bakery/document.cc:
+	* glom/libglom/utils.cc:
+	* glom/xsl_utils.cc: Avoid creating a Gio::File() from an empty URI,
+    avoiding useless stdout warnings at startup.
+
 2010-03-29  Daniel Borgmann  <danielb openismus com>
 
 	Edit Field Definition Dialog adjustments.
diff --git a/glom/application.cc b/glom/application.cc
index 74ce505..b7ce995 100644
--- a/glom/application.cc
+++ b/glom/application.cc
@@ -845,6 +845,9 @@ static bool uri_is_writable(const Glib::RefPtr<const Gio::File>& uri)
 
 Glib::ustring Application::get_file_uri_without_extension(const Glib::ustring& uri)
 {
+  if(uri.empty())
+    return uri;
+
   Glib::RefPtr<Gio::File> file = Gio::File::create_for_uri(uri);
   if(!file)
     return uri; //Actually an error.
diff --git a/glom/bakery/app_withdoc.cc b/glom/bakery/app_withdoc.cc
index 6c3fbd2..3c34148 100644
--- a/glom/bakery/app_withdoc.cc
+++ b/glom/bakery/app_withdoc.cc
@@ -192,6 +192,9 @@ void App_WithDoc::offer_saveas()
 
 bool App_WithDoc::file_exists(const Glib::ustring& uri)
 {
+  if(uri.empty())
+    return false;
+
   //Check whether file exists already:
   {
     // Try to examine the input file.
diff --git a/glom/libglom/connectionpool_backends/postgres_self.cc b/glom/libglom/connectionpool_backends/postgres_self.cc
index 042ee91..fc6b25c 100644
--- a/glom/libglom/connectionpool_backends/postgres_self.cc
+++ b/glom/libglom/connectionpool_backends/postgres_self.cc
@@ -747,6 +747,9 @@ int PostgresSelfHosted::discover_first_free_port(int start_port, int end_port)
 
 bool PostgresSelfHosted::create_text_file(const std::string& file_uri, const std::string& contents)
 {
+  if(file_uri.empty())
+    return false;
+
   Glib::RefPtr<Gio::File> file = Gio::File::create_for_uri(file_uri);
   Glib::RefPtr<Gio::FileOutputStream> stream;
 
@@ -821,7 +824,10 @@ bool PostgresSelfHosted::create_text_file(const std::string& file_uri, const std
 
 bool PostgresSelfHosted::directory_exists_uri(const std::string& uri)
 {
-  Glib::RefPtr<Gio::File> file = Gio::File::create_for_uri(uri);
+  if(uri.empty())
+    return false;
+
+  const Glib::RefPtr<Gio::File> file = Gio::File::create_for_uri(uri);
   return file && file->query_exists();
 }
 
diff --git a/glom/libglom/connectionpool_backends/sqlite.cc b/glom/libglom/connectionpool_backends/sqlite.cc
index 01df7bc..c16e115 100644
--- a/glom/libglom/connectionpool_backends/sqlite.cc
+++ b/glom/libglom/connectionpool_backends/sqlite.cc
@@ -46,13 +46,17 @@ const std::string& Sqlite::get_database_directory_uri() const
 
 Glib::RefPtr<Gnome::Gda::Connection> Sqlite::connect(const Glib::ustring& database, const Glib::ustring& username, const Glib::ustring& password, std::auto_ptr<ExceptionConnection>& error)
 {
+  Glib::RefPtr<Gnome::Gda::Connection> connection;
+  if(m_database_directory_uri.empty())
+    return connection;
+
   // Check if the database file exists. If it does not, then we don't try to
   // connect. libgda would create the database file if necessary, but we need
   // to ensure slightly different semantics.
   Glib::RefPtr<Gio::File> db_dir = Gio::File::create_for_uri(m_database_directory_uri);
   Glib::RefPtr<Gio::File> db_file = db_dir->get_child(database + ".db");
 
-  Glib::RefPtr<Gnome::Gda::Connection> connection;
+
   if(db_file->query_file_type() == Gio::FILE_TYPE_REGULAR)
   {
     // Convert URI to path, for GDA connection string
@@ -97,6 +101,9 @@ Glib::RefPtr<Gnome::Gda::Connection> Sqlite::connect(const Glib::ustring& databa
 
 bool Sqlite::create_database(const Glib::ustring& database_name, const Glib::ustring& /* username */, const Glib::ustring& /* password */, std::auto_ptr<Glib::Error>& error)
 {
+  if(m_database_directory_uri.empty())
+    return false;
+
   Glib::RefPtr<Gio::File> file = Gio::File::create_for_uri(m_database_directory_uri);
   const std::string database_directory = file->get_path(); 
   const Glib::ustring cnc_string = Glib::ustring::compose("DB_DIR=%1;DB_NAME=%2", database_directory, database_name);
diff --git a/glom/libglom/document/bakery/document.cc b/glom/libglom/document/bakery/document.cc
index 738529a..08fb936 100644
--- a/glom/libglom/document/bakery/document.cc
+++ b/glom/libglom/document/bakery/document.cc
@@ -203,6 +203,9 @@ bool Document::read_from_disk(int& failure_code)
   m_strContents.erase();
 
   // Open the input file for read access:
+  if(m_file_uri.empty())
+    return false;
+
   Glib::RefPtr<Gio::File> file = Gio::File::create_for_uri(m_file_uri);
 
   Glib::RefPtr<Gio::FileInputStream> stream;
@@ -280,6 +283,9 @@ bool Document::read_from_disk(int& failure_code)
 
 bool Document::write_to_disk()
 {
+  if(m_file_uri.empty())
+    return false;
+
   //Write the changed data to disk:
   if(get_modified())
   {
@@ -361,6 +367,9 @@ static Glib::ustring get_file_display_name(const Glib::ustring& uri)
 {
   Glib::ustring result;
 
+  if(uri.empty())
+    return result;
+
   Glib::RefPtr<Gio::File> file = Gio::File::create_for_uri(uri);
   Glib::RefPtr<const Gio::FileInfo> file_info;
 
@@ -371,7 +380,7 @@ static Glib::ustring get_file_display_name(const Glib::ustring& uri)
   }
   catch(const Glib::Error& ex)
   {
-    std::cerr << "Application::get_file_display_name(): error: " << ex.what() << std::endl;
+    std::cerr << "Application::get_file_display_name(uri=" << uri << "): error: " << ex.what() << std::endl;
     return result;
   }
 #else
diff --git a/glom/libglom/utils.cc b/glom/libglom/utils.cc
index 4f4fdd2..0eb629b 100644
--- a/glom/libglom/utils.cc
+++ b/glom/libglom/utils.cc
@@ -818,6 +818,9 @@ Glib::ustring Utils::string_remove_suffix(const Glib::ustring& str, const Glib::
 
 bool Utils::file_exists(const Glib::ustring& uri)
 {
+  if(uri.empty())
+     return false;
+
   //Check whether file exists already:
   {
     // Try to examine the input file.
diff --git a/glom/xsl_utils.cc b/glom/xsl_utils.cc
index f5e5ce4..dfbac55 100644
--- a/glom/xsl_utils.cc
+++ b/glom/xsl_utils.cc
@@ -73,9 +73,8 @@ void GlomXslUtils::transform_and_open(const xmlpp::Document& xml_document, const
   std::cout << "After xslt: " << result << std::endl;
 
   //Save it to a temporary file and show it in a browser:
-  //TODO: This actually shows it in gedit.
   const Glib::ustring temp_path = Glib::get_tmp_dir() + "/glom_printout.html";
-  std::cout << "temp_path=" << temp_path << std::endl;
+  //std::cout << "temp_path=" << temp_path << std::endl;
 
   Glib::RefPtr<Gio::File> file = Gio::File::create_for_path(temp_path);
   Glib::RefPtr<Gio::FileOutputStream> stream;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]