Bug#321599: [Gimp-print-devel] [patch] saved settings garbled with Auto orientation and PPI scaling
From: Roger Leigh <rleigh@whinlatter.ukfsn.org>
Date: Sun, 14 Aug 2005 10:16:06 +0100
tags 321599 + upstream
thanks
Robert,
The following patch was submitted to the Debian BTS to fix a problem
with the print dialogue in libgutenprintui2. It is surely also
equally applicable to libgutenprintui[1], so I've added that to the
patch.
The rationale for the change, and instructions for reproducing the
problem are available in the original bug report, which may be found
here:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=321599
It looks good, but since libgutenprintui is somewhat hairy, I thought
it could use some double-checking before I commit it.
Currently, printable_width and printable_height are only set in
preview_update when stp_get_imageable_area() is called.
stpui_compute_orientation is called out of set_orientation, and also
called out of plist.c just before printing (where this isn't an issue
any more).
set_orientation() is called out of do_all_updates(),
auto_paper_size_callback(), orientation_callback(), and
idle_preview_thumbnail().
In do_all_updates() it's called before invalidate_preview_thumbnail,
which is called before preview_update().
invalidate_preview_thumbnail() merely sets preview_valid to FALSE,
with no side effects.
auto_paper_size_callback() is called when the Auto Paper Size button
is clicked, which doesn't seem to be the issue here.
orientation_callback() is called when the orientation setting is
changed. This could be an issue, since the orientation gets set
during startup. However, the only place that orientation_menu gets
manipulated within the code (as opposed to from the UI) is in
do_all_updates, long after preview_update is called. The only thing
that the suppress_preview_update variable controls is whether the
idle_preview_thumbnail trigger is set.
idle_preview_thumbnail() is triggered out of preview_update() at the
end, to update the thumbnail when everything is idle. That wouldn't
seem to be the culprit here, since this only gets called after
printable_width and printable_height are set.
This suggests that the culprit is the call to set_orientation() out of
do_all_updates(). It's trying to set the orientation before
preview_update() has set the printable_width and printable_height, as
thought. The question is whether this is the best fix for the
problem; I'd rather not have this code duplicated (it's only going to
make analysis that much harder). One other potential concern I have
with this code is that stpui_compute_orientation() is globally scoped,
so someone could call it before pv is set up.
I was able to reproduce the problem with the instructions provided
(nicely filed bug report). I tried this fix, which appears to work
and which I believe better factors the code by computing the media
size and imageable area (which are closely related and is a logical
single operation to perform) in one place.
It's possible that putting a call to set_orientation() into
preview_update() would be a better solution.
Index: src/gutenprintui2/panel.c
===================================================================
RCS file: /cvsroot/gimp-print/print/src/gutenprintui2/panel.c,v
retrieving revision 1.4
diff -u -r1.4 panel.c
--- src/gutenprintui2/panel.c 30 Jun 2005 01:42:56 -0000 1.4
+++ src/gutenprintui2/panel.c 14 Aug 2005 14:20:56 -0000
@@ -2641,8 +2641,18 @@
}
static void
+compute_printable_region(void)
+{
+ stp_get_media_size(pv->v, &paper_width, &paper_height);
+ stp_get_imageable_area(pv->v, &left, &right, &bottom, &top);
+ printable_width = right - left;
+ printable_height = bottom - top;
+}
+
+static void
set_orientation(int orientation)
{
+ compute_printable_region();
pv->orientation = orientation;
if (orientation == ORIENT_AUTO)
orientation = stpui_compute_orientation();
@@ -4463,12 +4473,7 @@
gdouble min_ppi_scaling; /* Minimum PPI for current page size */
suppress_preview_update++;
- stp_get_media_size(pv->v, &paper_width, &paper_height);
-
- stp_get_imageable_area(pv->v, &left, &right, &bottom, &top);
-
- printable_width = right - left;
- printable_height = bottom - top;
+ compute_printable_region();
if (pv->scaling < 0)
{
Index: src/gutenprintui/panel.c
===================================================================
RCS file: /cvsroot/gimp-print/print/src/gutenprintui/panel.c,v
retrieving revision 1.3
diff -u -r1.3 panel.c
--- src/gutenprintui/panel.c 30 Jun 2005 01:42:56 -0000 1.3
+++ src/gutenprintui/panel.c 14 Aug 2005 09:12:09 -0000
@@ -2606,6 +2606,12 @@
gint
stpui_compute_orientation(void)
{
+ /* if this is called before preview_update() -- which happens on startup --
+ * then printable image area is not yet set */
+ stp_get_imageable_area(pv->v, &left, &right, &bottom, &top);
+ printable_width = right - left;
+ printable_height = bottom - top;
+
if (auto_paper_size ||
(printable_width >= printable_height &&
image_true_width >= image_true_height) ||
Index: src/gutenprintui2/panel.c
===================================================================
RCS file: /cvsroot/gimp-print/print/src/gutenprintui2/panel.c,v
retrieving revision 1.4
diff -u -r1.4 panel.c
--- src/gutenprintui2/panel.c 30 Jun 2005 01:42:56 -0000 1.4
+++ src/gutenprintui2/panel.c 14 Aug 2005 09:12:13 -0000
@@ -2630,6 +2630,12 @@
gint
stpui_compute_orientation(void)
{
+ /* if this is called before preview_update() -- which happens on startup --
+ * then printable image area is not yet set */
+ stp_get_imageable_area(pv->v, &left, &right, &bottom, &top);
+ printable_width = right - left;
+ printable_height = bottom - top;
+
if (auto_paper_size ||
(printable_width >= printable_height &&
image_true_width >= image_true_height) ||
--
Roger Leigh
Printing on GNU/Linux? http://gimp-print.sourceforge.net/
Debian GNU/Linux http://www.debian.org/
GPG Public Key: 0x25BFB848. Please sign and encrypt your mail.
-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Gimp-print-devel mailing list
Gimp-print-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gimp-print-devel
Reply to: