Re: error in constructor
| From: | Elizabeth M Smith | Date: | Mon, 31 Aug 2009 17:50:13 +0000 |
| Subject: | Re: error in constructor | ||
| References: | 1 2 | Groups: | php.gtk.general |
| Request: | Send a blank email to php-gtk-general+get-8431@lists.php.net to get a copy of this message | ||
Benjamin FOURTICQ wrote:
I imagine the constructor is called twice, because when you call $toto = new ProjectList() ProjectList::__construct() is called and so GtkTreeview::__construct(), then ProjectList::ProjectList() because it exists. In my opinion, if you just need to set the model use set_model() instead of calling the prent constructor. Hope this helps, Benjamin. Le 31/08/2009 19:07, Der Starchaser a écrit :ugh - if you want to override the constructor that's fine - do it using public function __construct() {} PHP 5 uses unified constructors - the "use the same function as the class name" support is a holdover for BC, please please don't use it in new code.... as you see it has some seriously odd side effects see the manual http://php.net/oop5.decon Thanks, ElizabethI want to program a class ProjectList, which is derived from class GtkTreeView. The following code snippet results in an assertion error. Is anybody able to explain me the error ? class ProjectList extends GtkTreeView {protected $store;/***********************************************************/ /* Constructor Method /***********************************************************/ function ProjectList() {$this->store = new GtkListStore( GObject::TYPE_STRING, GObject::TYPE_STRING );parent::__construct( $this->store );$col = 0; $column = $this->get_column(0); assert( $column ); //<- this line throws an assertion error $cell_renderer = new GtkCellRendererPixbuf(); $column->pack_start($cell_renderer, false);$column->set_cell_data_func( $cell_renderer, "prjlist_format_pixbuf", $this->Pixmap );}} // of class