RES: RES: RES: [PHP-GTK] PHP4 Object Issues.

From: Date: Wed, 03 Aug 2005 12:44:07 +0000
Subject: RES: RES: RES: [PHP-GTK] PHP4 Object Issues.
References: 1  Groups: php.gtk.general 
Request: Send a blank email to php-gtk-general+get-6138@lists.php.net to get a copy of this message
Hello, Just the & before the object instantiation made everything work :) Thanks Piero -----Mensagem original----- De: Malk0 [mailto:malk0.phpgtk@gmail.com] Enviada em: quarta-feira, 3 de agosto de 2005 09:22 Para: Piero B. Contezini Assunto: Re: RES: RES: [PHP-GTK] PHP4 Object Issues. hi piero first of all you have to change $janela_principal = new main_window(); $tool_box = new toolbox(); with $janela_principal = &new main_window(); $tool_box = &new toolbox(); doig this you'll be sure to work on the same object not copy of it, that's a really good habits to take when working with objects under php4. changing this $this->new_imagem->connect_object('destroy', array('main_window', 'destruir'),$this->new_imagem); to this $this->new_imagem->connect_object('destroy', array(&$main_window_instance, 'destruir'),$this->new_imagem); will ensure to call the method on the same object not a copy or blank object try this and tell me but i'm pretty sure your problem is due to the fact you work on copy or blank object instead of the previous one. What you seem to have problem with is the fact that php4 work with copy of object by default. To avoid more complication with this you have to work with reference. I know that's not a really easy thing to understand at first time and seems to be pretty weird, but it's really logic. look for previous post on this subject in the mailing's archive i'm sure you'll find some usefull info about this. Don't hesitate to ask for more info if you need i'll try to better explain if needed. regards, nathan 2005/8/3, Piero B. Contezini <piero@grupoamerican.com.br>: > Off course, let me explain: > > $janela_principal = new main_window(); > $tool_box = new toolbox(); > > The constructor of toolbox binds the ctree window and any widget i want > it to do. > > The main window has any window i want to generate in the execution flow, > except the ones especific to the toolbox. > > The function in the main_window class that calls the toolbox function > comes from this window: > > function new_imagem(&$pai) { > global $projeto; > $this->new_imagem = &new GtkWindow(); > $this->new_imagem->set_default_size(300,300); > $this->new_imagem->connect_object('destroy', > array('main_window', 'destruir'),$this->new_imagem); > $this->new_imagem->set_title("Nova Imagem"); > $this->new_imagem->set_border_width(10); > $this->new_imagem->add_accel_group($this->accelgroup); > > $ok_button->connect_object('clicked',array(&$this,'adicionar_imagem'),$t > his->new_imagem); > $cancel_button->connect_object('clicked', array(&$this, > 'destruir'),$this->new_imagem ); > } > > This are the registered callbacks, the function adicionar_imagem() > really calls add_toolbox from the toolbox object as follows: > > function adicionar_imagem($janela) { > global $tela_atual; > global $animacao_atual; > global $projeto; > global $tool_box; > > $imagem_nome = $this->imagementry->get_text(); > $imagem_caminho = $this->imagemcaminhoentry->get_text(); > $imagem_nivel = $this->nivelinput->get_text(); > $tool_box->add_toolbox($img); > > $this->destruir($janela); > > } > > This makes the thing more strange, as, it is not a callback to some > other object, it calls a function within the same object, that at the > end calls add_toolbox with the parameter to update the ctree list. > > Piero > > > -----Mensagem original----- > De: Malk0 [mailto:malk0.phpgtk@gmail.com] > Enviada em: terça-feira, 2 de agosto de 2005 18:26 > Para: Piero B. Contezini > Cc: bstumm@energytechnologysystems.com; php-gtk-general@lists.php.net > Assunto: Re: RES: [PHP-GTK] PHP4 Object Issues. > > Piero Can you explain how the methods are called inside your program? > > 2005/8/2, Piero B. Contezini <piero@grupoamerican.com.br>: > > If it is a global variable, i think this must assign the right > content, > > but it is inside a object, thats why i can't use the $GLOBALS array. > > > > > > Piero. > > > > -----Mensagem original----- > > De: Brian Stumm [mailto:bstumm@energytechnologysystems.com] > > Enviada em: terça-feira, 2 de agosto de 2005 18:16 > > Para: Piero B. Contezini > > Assunto: Re: [PHP-GTK] PHP4 Object Issues. > > > > Perhaps this is your problem.... > > > > If you would like to unset() a global variable inside of a function, > > you > > can use the $GLOBALS array to do so: > > > > <?php > > function foo() > > { > > unset($GLOBALS['bar']); > > } > > > > $bar = "something"; > > foo(); > > ?> > > > > See http://php.net/unset > > > > "Piero B. Contezini" wrote: > > > > > Know it seems to be really a PHP bug, > > > > > -- > > > > Brian Stumm > > ETS - Energy Technology Systems, Inc > > bstumm@energytechnologysystems.com > > http://energytechnologysystems.com > > > > -- > > PHP-GTK General Mailing List (http://gtk.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > -- > PHP-GTK General Mailing List (http://gtk.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > >

« previous php.gtk.general (#6138) next »