[Sugar-devel] Paint: trying to fix #1771

James Cameron quozl at laptop.org
Fri Jun 11 20:04:50 EDT 2010


On Fri, Jun 11, 2010 at 01:25:06AM -0300, Gonzalo Odiard wrote:
> I think it works, but i don't know if the right thing to do.
>
> From 97fb2adb1ea97a472e020244ae7a2d22c7a94db3 Mon Sep 17 00:00:00 2001
> From: Gonzalo Odiard <godiard at gmail.com>
> Date: Fri, 11 Jun 2010 01:22:36 -0300
> Subject: [PATCH] fix #1771 - paint overwrites file type instead of creating new file
>

Your patch was missing an explanation in the commit message, but during
review I tried to make an explanation.  I'll put the explanation here
and ask you to review it:

"Paint only writes type image/png.  It can load other types, but
overwrites as image/png.  This patch detects reading a type that is not
image/png, and forgets the association between the image being edited
and the journal entry that was read, so that the original journal entry
is not overwritten."

Does that match your understanding?

> http://bugs.sugarlabs.org/ticket/1771
> ---
>  OficinaActivity.py |    5 ++++-
>  1 files changed, 4 insertions(+), 1 deletions(-)
> 
> diff --git a/OficinaActivity.py b/OficinaActivity.py
> index c72576a..78bc8cf 100644
> --- a/OficinaActivity.py
> +++ b/OficinaActivity.py
> @@ -140,8 +140,8 @@ class OficinaActivity(activity.Activity):
>  
>      def read_file(self, file_path):
>          '''Read file from Sugar Journal.'''
> +        print 'reading file', file_path, "mime_type", self.metadata
> ['mime_type']
>  
> -        logging.debug('reading file %s', file_path)

Why did you change this to print?  If it was only temporary, change it
back.  If it is of use, change the logging.debug line.

Hint: since the logging level can't be changed once Sugar is started, I
change "debug" to "error" while I am testing code, and then change it
back to "debug" before committing the patch.

>  
>          pixbuf = gtk.gdk.pixbuf_new_from_file(file_path)
>  
> @@ -155,6 +155,9 @@ class OficinaActivity(activity.Activity):
>          self._setup_handle = self.fixed.connect('size_allocate',
>                  size_allocate_cb)
>  
> +        if self.metadata['mime_type'] != "image/png":
> +            self._jobject.object_id = None
> +

A comment would be useful here, because reading the code doesn't explain
why it is happening.  Something like:

# disassociate with journal entry to avoid overwrite (SL #1771)

>      def write_file(self, file_path):
>          '''Save file on Sugar Journal. '''
>  
> --
> 1.6.6.1

-- 
James Cameron
http://quozl.linux.org.au/


More information about the Sugar-devel mailing list