Re: Segmentation Fault?

From: Date: Sun, 18 Dec 2005 04:32:25 +0000
Subject: Re: Segmentation Fault?
References: 1  Groups: php.gtk.general 
Request: Send a blank email to php-gtk-general+get-6422@lists.php.net to get a copy of this message
Hi, Saturday, December 17, 2005, 11:45:39 PM, you wrote: AN> Hello All! AN> Was just wondering what a 'segmentation fault' was. It seems to appear AN> wherever a PHP-Gtk2 app is implemented in OOP style. The error doesn't AN> seem to occur in the same app implemented procedure style. Of course, AN> I am new to OOPS so I could have done something wrong there! AN> Is there really any advantage in programming OOP style? PHP-GTK itself AN> is OOP based, are there any serious drawbacks in writing apps that are AN> C-style using PHP-Gtk2? AN> On another note, I was just curious about the .phpw extension. The 'w' AN> is just a random character chosen to differentiate between PHP-Gtk AN> apps and regular php scripts, or is there any historical significance? AN> ;-) AN> I am attaching the program that gave me the segmentation fault (too AN> much to ask of you to read it, but, maybe someone has a lot of time on AN> their hands?!) It's the first object oriented program I've written so AN> forgive me for any obvious mistakes! AN> Thanks and Regards, AN> Anant AN> P.S. If you've seen the code and are curious what "Ring" is, it's an AN> attempt at creating an IDE for PHP-Gtk2. It's extremely primitive AN> stages now but I have a lot of ideas :-) Before delving into that, I'd AN> like to know if there's any ongoing project that attempts the same AN> thing, so that we can avoid duplication of effort. Christian has AN> however told me that there are no existing IDE's exclusively for AN> PHP-Gtk2. You need to add $accel to the GtkMenu not the gtkmenuItem. You also have a couple of typos and "" where not needed. This works for me in windows: <?php if (!class_exists('gtk')) { die('Please load the php-gtk2 module in your php.ini' . "\r\n"); } class Ring extends GtkWindow { function __construct() { parent::__construct(); $this->connect_simple("destroy", array('gtk', 'main_quit')); $this->set_title("RING: Ring Is Not Glade!"); $thevbox = new GtkVBox(); $thehbox = new GtkHBox(); $themenu = new RingMenu(); $themenu->addIMenu("_File", "fAcc", array("gtk-new", "gtk-open", "gtk-save", "gtk-save-as", "RING.Sep", "gtk-quit"), array("test", "test", "test", "test", " ", array('gtk', 'main_quit'))); $thevbox->pack_start($themenu); $this->add($thevbox); $this->show_all(); } } class RingMenu extends GtkMenuBar { function __construct() { parent::__construct(); } function addIMenu($mname, $agrp, $names, $callbacks) { $i = 0; $accel = new GtkAccelGroup($agrp); $smenu = new GtkMenu(); $smenu->set_accel_group($accel); foreach($names as $val) { if($val!='RING.Sep') { $item = new GtkImageMenuItem($val); $item->connect_simple("activate", $callbacks[$i]); $smenu->append($item); } else { //$item = new GtkSeperatorMenuItem(); not implemented $item = new GtkImageMenuItem(''); $item->set_sensitive(false); $smenu->append($item); } $i=$i+1; } $tmenu = new GtkMenuItem($mname); $tmenu->set_submenu($smenu); $this->add($tmenu); } } new Ring(); Gtk::main(); ?> -- regards, Tom

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