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 354353 - entry fires changed signal twice, once empty
entry fires changed signal twice, once empty
Status: RESOLVED DUPLICATE of bug 64998
Product: gtk+
Classification: Platform
Component: Widget: Other
2.8.x
Other All
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2006-09-04 21:58 UTC by Joachim Breitner
Modified: 2006-09-04 22:32 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Joachim Breitner 2006-09-04 21:58:25 UTC
Hi,

When I set an entry2 in the changed signal for another entry1, the entry2 itself fire the signal twice, once with the field empty, and once with the real value.

The following python code demonstrates it. Same logig in Haskell has same results, so I don't think it's a bug in the bindings:

=====================================================
import pygtk
import gtk

def e1(w):
  text = entry1.get_text()
  print "entry1: %s"%text
  entry2.set_text(text)
 
def e2(w):
  text = entry2.get_text()
  print "entry2: %s"%text
  button.set_label(text)
 
window = gtk.Window()
button = gtk.Button()
entry1 = gtk.Entry()
entry2 = gtk.Entry()
vbox   = gtk.VBox()
vbox.add(entry1)
vbox.add(entry2)
vbox.add(button)
window.add(vbox)
button.set_label("Test it")
entry1.connect("changed", e1)
entry2.connect("changed", e2)
button.connect("clicked", lambda: entry1.set_text("test"))

window.show_all()
gtk.main()
=====================================================

Output when user changes entry one from "s" to "ss":
entry1: ss
entry2:
entry2: ss
Happens like that for every key press in entry1, unless entry2 was empty before, In this case 
entry1: s
entry2: s
Like it should be.


By looking at the code at http://cvs.gnome.org/viewcvs/gtk%2B/gtk/gtkentry.c?rev=1.323&view=markup I see that setting the text first deletes the text and then inputs it, so that's probably the cause. My suggestions would be to either try to no raise a signal when deleting, or by bypassing these two functions somehow. But I'm not gtk developer, there might be better solutions...


I'd appreciate if this could be fixed. Thanks!
Comment 1 Joachim Breitner 2006-09-04 22:32:50 UTC
Allright, looks like I'm not good in searching the bugzilla...

*** This bug has been marked as a duplicate of 64998 ***