Merge lp:~openerp-dev/openobject-client/6.1-opw-573456-xal into lp:openobject-client/6.1

Proposed by Xavier ALT
Status: Merged
Approved by: Naresh(OpenERP)
Approved revision: 2059
Merged at revision: 2076
Proposed branch: lp:~openerp-dev/openobject-client/6.1-opw-573456-xal
Merge into: lp:openobject-client/6.1
Diff against target: 23 lines (+2/-2)
1 file modified
bin/widget/view/form_gtk/image.py (+2/-2)
To merge this branch: bzr merge lp:~openerp-dev/openobject-client/6.1-opw-573456-xal
Reviewer Review Type Date Requested Status
Naresh(OpenERP) (community) Approve
Review via email: mp+103437@code.launchpad.net

Description of the change

Hi,

When displaying image within the GTK client using "image" widget, sometime the image appears as empty. This is especially the case on Win7, but the problem happens all the time.

The MP fix the usage of gtk.gdk.PixbufLoader() by forcing a "close" before trying to get the image pixbuf.

Before as close() was happening later-on, there is a short period of time where the PixbufLoader() might not have processed the picure; period of time where get_pixbuf() return None. That lead the GTK client think there is no valid picture of that format, which is wrong.

Regards,
Xavier

To post a comment you must log in.
Revision history for this message
Naresh(OpenERP) (nch-openerp) wrote :

Hello Xavier,

I think the problem does not seem to stem from missing the closing of the loader. but it may be due to lack of setting the fields value in the model field while adding new image !

nch@Naresh:~/workspace/OpenERP2012/6.1/client/bin$ bzr diff
=== modified file 'bin/widget/view/form_gtk/image.py'
--- bin/widget/view/form_gtk/image.py 2011-09-26 12:53:49 +0000
+++ bin/widget/view/form_gtk/image.py 2012-07-17 11:06:16 +0000
@@ -114,9 +114,11 @@
         if filename:
             self._value = encodestring(file(filename, 'rb').read())
             self.update_img()
+ self.set_value(self._view.model, self._view.model.mgroup.mfields[self.attrs['name']])
             if self.has_filename and self.has_filename in self._view.model.mgroup.mfields:
                 self._view.model.set({self.has_filename: os.path.basename(filename)}, modified=True)

can you please check with this....

Thanks,
Naresh

review: Needs Information
Revision history for this message
Xavier ALT (dex-phx) wrote :

Hi Naresh,

Just tested a new GTK build including your proposed fix, but this doesn't work - "image" widget stay blank.

I think this issue is essentially related to the fact that gtk.gdk.PixbufLoader() is mainly used for loading image progressively - generating "preview" of image based on current fetched data.

  But I think there is some heuristic in there that might delay generation of the "preview", so by using "close()" it only indicate to PixbufLoader() that there is no more data to come - and that is can generate the definite image buffer.

Cheers,
Xavier

Revision history for this message
Naresh(OpenERP) (nch-openerp) wrote :

Hi Xavier,

Thanks for the information:

I had a doubt in this because I came across similar bug https://bugs.launchpad.net/openobject-client/+bug/950112 and linked MP https://code.launchpad.net/~openerp-dev/openobject-client/6.1-opw-573333-ado/+merge/100075 where the patch I proposed worked there. Infact this happens on ubuntu versions too.

Thanks,
Naresh

Revision history for this message
Xavier ALT (dex-phx) wrote :

Hi Naresh,

Just tested on Win7, on product <field name="xxx" widget='image'/> works with my patch, but adding "filename="default_code" raise the issue from OPW 573333, so for me it's really differents bugs.

You can try with the following build which include fix of the current MP (but not the one of 573333):

http://ubuntuone.com/3zbubIoNIwyDs2Tzqayg4K

Cheers,
Xavier

Revision history for this message
Naresh(OpenERP) (nch-openerp) wrote :

ok it seems the same what you say..Thanks I will merge it to stable

Thanks,
Naresh

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/widget/view/form_gtk/image.py'
2--- bin/widget/view/form_gtk/image.py 2011-09-26 12:53:49 +0000
3+++ bin/widget/view/form_gtk/image.py 2012-04-25 10:11:19 +0000
4@@ -185,6 +185,7 @@
5 loader = gtk.gdk.PixbufLoader(type)
6 try:
7 loader.write(data, len(data))
8+ loader.close()
9 except:
10 continue
11 pixbuf = loader.get_pixbuf()
12@@ -193,10 +194,9 @@
13 if not pixbuf:
14 loader = gtk.gdk.PixbufLoader('png')
15 loader.write(NOIMAGE, len(NOIMAGE))
16+ loader.close()
17 pixbuf = loader.get_pixbuf()
18
19- loader.close()
20-
21 img_height = pixbuf.get_height()
22 if img_height > self.height:
23 height = self.height

Subscribers

People subscribed via source and target branches