sane-project-website/old-archive/1997-11/0043.html

134 wiersze
6.1 KiB
HTML

<!-- received="Mon Nov 3 23:56:20 1997 PST" -->
<!-- sent="Tue, 4 Nov 1997 02:56:13 -0500" -->
<!-- name="Matto Marjanovic" -->
<!-- email="maddog@mir.com" -->
<!-- subject="Re: gamma-bind infinite loops in 0.67" -->
<!-- id="199711040756.CAA10845@yoo-hoo.ai.mit.edu" -->
<!-- inreplyto="gamma-bind infinite loops in 0.67" -->
<title>sane-devel: Re: gamma-bind infinite loops in 0.67</title>
<h1>Re: gamma-bind infinite loops in 0.67</h1>
<b>Matto Marjanovic</b> (<a href="mailto:maddog@mir.com"><i>maddog@mir.com</i></a>)<br>
<i>Tue, 4 Nov 1997 02:56:13 -0500</i>
<p>
<ul>
<li> <b>Messages sorted by:</b> <a href="date.html#43">[ date ]</a><a href="index.html#43">[ thread ]</a><a href="subject.html#43">[ subject ]</a><a href="author.html#43">[ author ]</a>
<!-- next="start" -->
<li> <b>Next message:</b> <a href="0044.html">becka@rz.uni-duesseldorf.de: "Re: JAVA version"</a>
<li> <b>Previous message:</b> <a href="0042.html">Reginald Stadlbauer: "Scanner driver"</a>
<li> <b>Maybe in reply to:</b> <a href="0038.html">Matto Marjanovic: "gamma-bind infinite loops in 0.67"</a>
<!-- nextthread="start" -->
<li> <b>Next in thread:</b> <a href="0053.html">David Mosberger-Tang: "Re: gamma-bind infinite loops in 0.67"</a>
<li> <b>Reply:</b> <a href="0053.html">David Mosberger-Tang: "Re: gamma-bind infinite loops in 0.67"</a>
<!-- reply="end" -->
</ul>
<!-- body="start" -->
Well, I don't know what changed in xscanimage/gtkglue/gtk, but herein lies<br>
a patch, and explanation of what was happening.<br>
<p>
But, before that, I think that in light of all this, a good programming<br>
policy should be: <br>
<p>
For backend writers: Be careful not to set RELOAD_PARAMS or RELOAD_OPTIONS<br>
if nothing has really changed, i.e. if some option<br>
just gets set to the value it already had.<br>
(This is what that umax patch fixed, and this is <br>
something I need to fix in the microtek backend.)<br>
<p>
For frontend writers: Be careful not to unnecessarily set options that<br>
are already set to the intended value.<br>
Kind of pedantic, I guess, but maybe there's a use<br>
for options with non-stationary side-effects, or<br>
something like that.<br>
<p>
The backend suggestion is actually directly counter to what is written in<br>
the API documentation for sane_control_option:<br>
<p>
SANE_INFO_RELOAD_OPTIONS<br>
<p>
.....When this happens, the SANE backend sets this member in *i to<br>
indicate that the application should reload all options. __Note that this<br>
member may be set even if no other option changed.__ However, it is<br>
guaranteed that other options never change without this member being set.<br>
<p>
Perhaps the API spec should be modified; either way, one of the two above<br>
needs to be put in effect.<br>
<p>
<p>
<p>
Anyhow, the problem with xscanimage is this loop:<br>
<p>
o xscanimage sets some Boolean option which returns a RELOAD_OPTIONS.<br>
o In doing RELOAD_OPTIONS, xscanimage rebuilds dialog box from scratch.<br>
o So, the checkbox for the Boolean option is regenerated:<br>
o The checkbox widget is created<br>
o The `toggle' signal is connected to the callback function<br>
o The initial value is set, but this triggers the callback...<br>
o so xscanimage sets the Boolean option again... etc.<br>
<p>
The following patch breaks this loop, by having the initial value of a<br>
Boolean Checkbox set before the callback signal is attached. This actually<br>
seems to follow in the model of the other new widget functions, so it's<br>
probably not a bad thing after all.<br>
<p>
You can apply the patch as follows:<br>
<p>
cd xxxxxx/sane-0.67/frontend<br>
patch &lt; gtkglue.patch [or, whatever file you put it in]<br>
<p>
<p>
_Matt M._<br>
<p>
==============================================================================<br>
--- gtkglue.c.orig Tue Nov 4 02:28:54 1997<br>
+++ gtkglue.c Tue Nov 4 02:26:36 1997<br>
@@ -376,12 +376,13 @@<br>
}<br>
<br>
static void<br>
-button_new (GtkWidget * parent, const char *name, GSGDialogElement * elem,<br>
- GtkTooltips *tooltips, const char *desc)<br>
+button_new (GtkWidget * parent, const char *name, SANE_Word val,<br>
+ GSGDialogElement * elem, GtkTooltips *tooltips, const char *desc)<br>
{<br>
GtkWidget *button;<br>
<br>
button = gtk_check_button_new_with_label ((char *) name);<br>
+ gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (button), val);<br>
gtk_signal_connect (GTK_OBJECT (button), "toggled",<br>
(GtkSignalFunc) button_update,<br>
elem);<br>
@@ -935,14 +936,12 @@<br>
<br>
case SANE_TYPE_BOOL:<br>
assert (opt-&gt;size == sizeof (SANE_Word));<br>
- button_new (parent, title, elem, dialog-&gt;tooltips, opt-&gt;desc);<br>
-<br>
status = sane_control_option (dialog-&gt;dev, i, SANE_ACTION_GET_VALUE,<br>
&amp;val, 0);<br>
if (status != SANE_STATUS_GOOD)<br>
goto get_value_failed;<br>
<br>
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (elem-&gt;widget), val);<br>
+ button_new (parent, title, val, elem, dialog-&gt;tooltips, opt-&gt;desc);<br>
gtk_widget_show (parent-&gt;parent);<br>
break;<br>
<br>
<p>
<pre>
--
Source code, list archive, and docs: <a href="http://www.mostang.com/sane/">http://www.mostang.com/sane/</a>
To unsubscribe: echo unsubscribe sane-devel | mail <a href="mailto:majordomo@mostang.com">majordomo@mostang.com</a>
</pre>
<!-- body="end" -->
<p>
<ul>
<!-- next="start" -->
<li> <b>Next message:</b> <a href="0044.html">becka@rz.uni-duesseldorf.de: "Re: JAVA version"</a>
<li> <b>Previous message:</b> <a href="0042.html">Reginald Stadlbauer: "Scanner driver"</a>
<li> <b>Maybe in reply to:</b> <a href="0038.html">Matto Marjanovic: "gamma-bind infinite loops in 0.67"</a>
<!-- nextthread="start" -->
<li> <b>Next in thread:</b> <a href="0053.html">David Mosberger-Tang: "Re: gamma-bind infinite loops in 0.67"</a>
<li> <b>Reply:</b> <a href="0053.html">David Mosberger-Tang: "Re: gamma-bind infinite loops in 0.67"</a>
<!-- reply="end" -->
</ul>