Benjamin Smith wrote:
Say that there are two buttons on the screen, each of which take a few moments
to process. If the user presses button A, and starts the process, and then
presses button B before A's callback is done, then both callbacks
are "running at the same time".
This has resulted in some inconsistent states and program crashes. (EG: the
callback for button A assumes that a certain object is defined, but since
button B was pressed before A was done, that object is no longer there)
Is this making sense? What's the best way to structure things to deal with
this issue?
Hi Benjamin,
There are many ways to handle "concurrent" button clicks in PHP-GTK2. Below are three of the methods:
Method 1: using GObject::block()
Method 2: using GtkWidget::set_sensitive()
Method 3: GObject::emit_stop_by_name()
Sample codes as follows:
http://www.kksou.com/php-gtk2/articles/prevent-concurrent-button-clicks---Part-1---using-block.phphttp://www.kksou.com/php-gtk2/articles/prevent-concurrent-button-clicks---Part-2---using-set-sensitive.phphttp://www.kksou.com/php-gtk2/articles/prevent-concurrent-button-clicks---Part-3---using-emit-stop-by-name.phpRegards,
/kksou