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 584937 - Bug#531892 Gtk-CRITICAL when sending an empty file
Bug#531892 Gtk-CRITICAL when sending an empty file
Status: RESOLVED FIXED
Product: gnome-bluetooth
Classification: Core
Component: sendto
2.27.x
Other Linux
: Normal normal
: ---
Assigned To: gnome-bluetooth-general-maint@gnome.bugs
gnome-bluetooth-general-maint@gnome.bugs
Depends on:
Blocks:
 
 
Reported: 2009-06-05 16:05 UTC by Filippo Giunchedi
Modified: 2009-06-08 10:35 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Filippo Giunchedi 2009-06-05 16:05:19 UTC
[forwarding from http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=531892]

Hi,

When sending an empty file using bluetooth-sendto, I get the following Gtk-CRITICAL messages:

% touch empty.txt
% bluetooth-sendto empty.txt

(bluetooth-sendto:5848): Gtk-CRITICAL **: gtk_progress_set_percentage: assertion `percentage >= 0 && percentage <= 1.0' failed

(bluetooth-sendto:5848): Gtk-CRITICAL **: gtk_progress_set_percentage: assertion `percentage >= 0 && percentage <= 1.0' failed


After some investigation, I suspect that the following code has a possible "divide by zero" problem.

gnome-bluetooth-2.27.5/sendto/main.c:
static void transfer_progress(DBusGProxy *proxy,
                                        guint64 bytes, gpointer user_data)
{
...
        current_sent = total_sent + bytes;
        fraction = (gdouble) current_sent / (gdouble) total_size; <<==
        gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progress), fraction);

Note that total_size will be 0 if the file size is 0.


I suggest the following patch to fix the problem.

--- gnome-bluetooth-2.27.5.orig/sendto/main.c   2009-04-17 21:39:23.000000000 +0900
+++ gnome-bluetooth-2.27.5/sendto/main.c        2009-06-05 03:57:17.000000000 +0900
@@ -299,7 +299,10 @@
        gchar *time, *rate, *file, *text;

        current_sent = total_sent + bytes;
-       fraction = (gdouble) current_sent / (gdouble) total_size;
+       if (total_size == 0)
+               fraction = 1.0;
+       else
+               fraction = (gdouble) current_sent / (gdouble) total_size;
        gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progress), fraction);

        current_time = get_system_time();


Regards,
Comment 1 Bastien Nocera 2009-06-08 10:35:07 UTC
Thanks for the pointer. I committed a slightly different fix (which actually shows "progress", so we're only at 100% when the transfer successfully finished).

commit a83242b14079cd8d13bb462159f6147f9a9345df
Author: Bastien Nocera <hadess@hadess.net>
Date:   Mon Jun 8 11:33:18 2009 +0100

    Bug 584937Bug#531892 Gtk-CRITICAL when sending an empty file
    
    When sending an empty file (or empty files), set the progress bar
    to 0.0 when starting the transfer, and to 1.0 when it has finished.