After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 445093 - Transfer::transfer() without progress_callback argument does not work
Transfer::transfer() without progress_callback argument does not work
Status: RESOLVED FIXED
Product: gnome-vfsmm
Classification: Deprecated
Component: general
git master
Other All
: Normal minor
: ---
Assigned To: gtkmm-forge
gtkmm-forge
Depends on:
Blocks:
 
 
Reported: 2007-06-07 12:27 UTC by Sergio Perticone
Modified: 2011-01-16 23:36 UTC
See Also:
GNOME target: ---
GNOME version: 2.17/2.18



Description Sergio Perticone 2007-06-07 12:27:18 UTC
Please describe the problem:
Gnome::Vfs::Transfer::transfer takes an optional argument for a progress
callback (SlotProgress). When this argument is no specified the function does not work properly, basically it throws, always, an exception (operation interrupted).

Steps to reproduce:
using namespace Gnome;

Vfs::init();

try {
      Vfs::Transfer::transfer(src, dest);                      
}
catch(const Vfs::exception& e) {
      g_print("%s\n", e.what().data());
}

Actual results:
It prints "Operation interrupted".

Expected results:
According to reference, it should copy "src" to "dest"

Does this happen every time?
Yes.

Other information:
Well, I wrote this (see below).
Basically the "old" transfer() is overloaded with a new transfer() :

transfer(const <string or uri> src, const <string or uri> target,
           TransferOptions options = XFER_DEFAULT,
           ErrorMode error_mode = XFER_ERROR_MODE_ABORT,
           OverwriteMode overwrite_mode = XFER_OVERWRITE_MODE_ABORT)

The "old" function now is:

transfer(const <string or uri> src, const <string or uri> target,
           TransferOptions options,
           ErrorMode error_mode,
           OverwriteMode overwrite_mode,
           const SlotProgress& progress_callback)

The arguments are mandatory (to avoid ambiguity), if you don't like this
we can "move" SlotProgress argument back...

I changed also functions with std::auto_ptr<> parameter

The patch is against gnome-vfsmm-2.18.0 but, if you want, I can edit also the svn branch
----

Index: transfer.cc
===================================================================
--- transfer.cc	(revision 1076)
+++ transfer.cc	(working copy)
@@ -203,6 +203,52 @@
 }
 
 #ifdef GLIBMM_EXCEPTIONS_ENABLED
+void transfer(const Glib::ustring& source_uri, const Glib::ustring& target_uri,
+      TransferOptions options,
+      ErrorMode error_mode,
+      OverwriteMode overwrite_mode)
+#else
+void transfer(const Glib::ustring& source_uri, const Glib::ustring& target_uri,
+      TransferOptions options,
+      ErrorMode error_mode,
+      OverwriteMode overwrite_mode,
+      std::auto_ptr<Gnome::Vfs::exception>& error)
+#endif //GLIBMM_EXCEPTIONS_ENABLED
+{
+  #ifdef GLIBMM_EXCEPTIONS_ENABLED
+  return transfer( Uri::create(source_uri), Uri::create(target_uri), options, error_mode, overwrite_mode);
+  #else
+  return transfer( Uri::create(source_uri), Uri::create(target_uri), options, error_mode, overwrite_mode, error);
+  #endif //GLIBMM_EXCEPTIONS_ENABLED
+}
+
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+void transfer(const Glib::RefPtr<const Uri>& source_uri, const Glib::RefPtr<const Uri>& target_uri,
+      TransferOptions options, 
+      ErrorMode error_mode,
+      OverwriteMode overwrite_mode)
+#else
+void transfer(const Glib::RefPtr<const Uri>& source_uri, const Glib::RefPtr<const Uri>& target_uri,
+      TransferOptions options, 
+      ErrorMode error_mode,
+      OverwriteMode overwrite_mode,
+      std::auto_ptr<Gnome::Vfs::exception>& error)
+#endif //GLIBMM_EXCEPTIONS_ENABLED
+{
+  GnomeVFSResult result = gnome_vfs_xfer_uri(source_uri->gobj(), target_uri->gobj(),
+    static_cast<GnomeVFSXferOptions>(options),
+    static_cast<GnomeVFSXferErrorMode>(error_mode),
+    static_cast<GnomeVFSXferOverwriteMode>(overwrite_mode),
+    NULL, NULL);
+    
+  #ifdef GLIBMM_EXCEPTIONS_ENABLED
+  handle_result(result);
+  #else
+  handle_result(result, error);
+  #endif //GLIBMM_EXCEPTIONS_ENABLED
+}
+
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
 void remove(const Glib::ustring& source_uri,
       TransferOptions options,
       ErrorMode error_mode,
Index: transfer.h
===================================================================
--- transfer.h	(revision 1076)
+++ transfer.h	(working copy)
@@ -98,16 +98,45 @@
 
 #ifdef GLIBMM_EXCEPTIONS_ENABLED
 void transfer(const Glib::ustring& source_uri, const Glib::ustring& target_uri,
+      TransferOptions options,
+      ErrorMode error_mode,
+      OverwriteMode overwrite_mode,
+      const SlotProgress& progress_callback);
+#else
+void transfer(const Glib::ustring& source_uri, const Glib::ustring& target_uri,
+      TransferOptions options, //TODO: Does Default do anything useful?
+      ErrorMode error_mode,
+      OverwriteMode overwrite_mode,
+      const SlotProgress& progress_callback,
+      std::auto_ptr<Gnome::Vfs::exception>& error);
+#endif //GLIBMM_EXCEPTIONS_ENABLED
+      
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+void transfer(const Glib::RefPtr<const Uri>& source_uri, const Glib::RefPtr<const Uri>& target_uri,
+      TransferOptions options,
+      ErrorMode error_mode,
+      OverwriteMode overwrite_mode,
+      const SlotProgress& progress_callback);
+#else
+void transfer(const Glib::RefPtr<const Uri>& source_uri, const Glib::RefPtr<const Uri>& target_uri,
+      TransferOptions options, //TODO: Does Default do anything useful?
+      ErrorMode error_mode,
+      OverwriteMode overwrite_mode,
+      const SlotProgress& progress_callback,
+      std::auto_ptr<Gnome::Vfs::exception>& error);
+#endif //GLIBMM_EXCEPTIONS_ENABLED
+
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+void transfer(const Glib::ustring& source_uri, const Glib::ustring& target_uri,
       TransferOptions options = XFER_DEFAULT, //TODO: Does Default do anything useful?
       ErrorMode error_mode = XFER_ERROR_MODE_ABORT,
-      OverwriteMode overwrite_mode = XFER_OVERWRITE_MODE_ABORT,
-      const SlotProgress& progress_callback = SlotProgress());
+      OverwriteMode overwrite_mode = XFER_OVERWRITE_MODE_ABORT);
+
 #else
 void transfer(const Glib::ustring& source_uri, const Glib::ustring& target_uri,
       TransferOptions options, //TODO: Does Default do anything useful?
       ErrorMode error_mode,
       OverwriteMode overwrite_mode,
-      const SlotProgress& progress_callback,
       std::auto_ptr<Gnome::Vfs::exception>& error);
 #endif //GLIBMM_EXCEPTIONS_ENABLED
       
@@ -115,14 +144,13 @@
 void transfer(const Glib::RefPtr<const Uri>& source_uri, const Glib::RefPtr<const Uri>& target_uri,
       TransferOptions options = XFER_DEFAULT, //TODO: Does Default do anything useful?
       ErrorMode error_mode = XFER_ERROR_MODE_ABORT,
-      OverwriteMode overwrite_mode = XFER_OVERWRITE_MODE_ABORT,
-      const SlotProgress& progress_callback = SlotProgress());
+      OverwriteMode overwrite_mode = XFER_OVERWRITE_MODE_ABORT);
+
 #else
 void transfer(const Glib::RefPtr<const Uri>& source_uri, const Glib::RefPtr<const Uri>& target_uri,
       TransferOptions options, //TODO: Does Default do anything useful?
       ErrorMode error_mode,
       OverwriteMode overwrite_mode,
-      const SlotProgress& progress_callback,
       std::auto_ptr<Gnome::Vfs::exception>& error);
 #endif //GLIBMM_EXCEPTIONS_ENABLED
 
@@ -168,7 +196,7 @@
 void remove_list_uris(const ListHandleUris& source_uri_list,
       TransferOptions options,
       ErrorMode error_mode,
-      const SlotProgress& progress_callbacki,
+      const SlotProgress& progress_callback,
       std::auto_ptr<Gnome::Vfs::exception>& error);
 #endif //GLIBMM_EXCEPTIONS_ENABLED
Comment 1 Murray Cumming 2008-01-03 09:21:02 UTC
Sorry for the delay in responding. I believe that we fixed this since you filed this bug:

2007-10-06  Armin Burgmeier  <armin@openismus.com>

	* examples/transfer/main.cc:
	* examples/async/main.cc: Fixed build with disabled exceptions.

In future, please attach patches instead of pasting them, and try to create svn patches - you patched generated files.

By the way, unless you are using gtkmm for embedded use, you really don't need to build with disabled exceptions.