PHP-GTK2 Cookbook Forum
Welcome, Guest
Please Login or Register.    Lost Password?
Re:Segmentation fault - PHPGTK Treeview (1 viewing) (1) Guest
Go to bottom Post Reply Favoured: 0
TOPIC: Re:Segmentation fault - PHPGTK Treeview


#5318
khmedia (User)
Fresh Boarder
Posts: 3
graphgraph
User Offline Click here to see the profile of this user
Segmentation fault - PHPGTK Treeview 11 Months, 2 Weeks ago Karma: 0  
Hello friends,
This code is throwing a Segmentation fault. Please help:

Code:
function transpose_ledger($tab_label, $tab_color)
{
	global $db, $ledger_list_cols;
	$vbox = create_master_box($tab_label, $tab_color);
	
	$liststore = new GtkListStore(GObject::TYPE_LONG, GObject::TYPE_STRING, GObject::TYPE_STRING, 
		GObject::TYPE_STRING, GObject::TYPE_STRING, GObject::TYPE_STRING, GObject::TYPE_STRING,
		GObject::TYPE_STRING, GObject::TYPE_STRING, GObject::TYPE_STRING, GObject::TYPE_LONG);
	
	$result = $db->query_limit('ledgers');
	$m = 1;
	foreach ($result as $record)
	{
		$iter = $liststore->append();
		$liststore->set($iter, 
			0, $m,
			1, $record['demandno'],
			2, $record['censusno'], 
			3, $record['year'],
			4, $record['name'],
			5, $record['caste'],
			6, $record['address'],
			7, $record['mobile'],
			8, $record['colony'],
			9, $record['houseno'],
			10, $record['wardno']
		);
		$m++;
	}
	
	$tree = new GtkTreeView();
	$tree->set_model($liststore);
	
	$i = 0;
	foreach ($ledger_list_cols as $col_caption => $justification)
	{
		$renderer = new GtkCellRendererText();
		$renderer->set_property('xalign', $justification);
		$col = new GtkTreeViewColumn($col_caption, $renderer, 'text', $i);
		
		$label = new GtkLabel($col_caption);
		$label->modify_fg(Gtk::STATE_NORMAL, GdkColor::parse('blue'));
		$col->set_widget($label);
		$label->show();
		
		$tree->append_column($col);
		$col->set_cell_data_func($renderer, "format_columns", $i);
			
		$i++;
	}
	
	$scrolled_win = new GtkScrolledWindow();
	$scrolled_win->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
	
	$scrolled_win->add($tree);
	
	$vbox->add($scrolled_win);
	
	return $vbox;
}
Code:
function format_columns($column, $cell, $model, $iter, $col_num)
{
	$path = $model->get_path($iter);
	$row_num = $path[0];
	$val = $model->get_value($iter, $col_num);
	
	if ($col_num==4 || $col_num==5 || $col_num==6 || $col_num==8)
		$renderer->set_property('markup', "<span font_desc='Kruti Dev 010 14'>$val</span>");

  $row_color = ($col_num%2==1) ? '#dddddd' : '#ffffff';
  $cell->set_property('cell-background', $row_color);
}
 
  The administrator has disabled public write access.

#5321
cubii (User)
Fresh Boarder
Posts: 6
graphgraph
User Offline Click here to see the profile of this user
Re:Segmentation fault - PHPGTK Treeview 11 Months, 2 Weeks ago Karma: 0  
More info please. Are you using Windows, Mac or Linux to run this? And is it at runtime it seg faults? Or does it run, but when you go to do something, it doesn't work and bombs out?
 
  The administrator has disabled public write access.

#5322
khmedia (User)
Fresh Boarder
Posts: 3
graphgraph
User Offline Click here to see the profile of this user
Re:Segmentation fault - PHPGTK Treeview 11 Months, 2 Weeks ago Karma: 0  
You can say that its during runtime. Actually I use Ubuntu Linux for my phpgtk needs. If I remove this line, the error goes away.

$col->set_cell_data_func($renderer, "format_columns", $i);
 
  The administrator has disabled public write access.
#5323
kksou (Admin)
Admin
Posts: 1676
graph
User Online Now Click here to see the profile of this user
Re:Segmentation fault - PHPGTK Treeview 11 Months, 2 Weeks ago Karma: 27  
Hi,

It means you didn't compile your PHP-GTK2 correctly. The function set_cell_data_func() is not found, hence the error message.

You might want to try recompile php-gtk2 using all the latest libraries.

Regards,
/kksou
 
  The administrator has disabled public write access.
#5325
khmedia (User)
Fresh Boarder
Posts: 3
graphgraph
User Offline Click here to see the profile of this user
Re:Segmentation fault - PHPGTK Treeview 11 Months, 2 Weeks ago Karma: 0  
No luck,

Recompiled phpgtk but no luck ! still facing same error. The compilation gone perfectly.

Download from trunk
extract
./configure
make
sudo make install
 
 
Last Edit: 2012/06/08 01:16 By khmedia. Reason: additions
  The administrator has disabled public write access.
#5330
kksou (Admin)
Admin
Posts: 1676
graph
User Online Now Click here to see the profile of this user
Re:Segmentation fault - PHPGTK Treeview 11 Months, 2 Weeks ago Karma: 27  
Hi,

Every linux is slightly different. You have to compile the PHP-GTK that runs on your linux. So it's very difficult for me to help you here.

I have written the following article back in 2006:
Sample Code 66: How to install php gtk2 on linux?

Yes, some of the content might be outdated. But if you follow the same steps (of course replacing the respective libraries with the latest versions), I think you will still be able to compile the PHP-GTK2. The key thing is: the article outlined all the key libraries that you need to make a running PHP-GTK2 for your linux.

You could also do some googling to see if there are more recent articles on how to compile PHP-GTK2.

Regards,
/kksou
 
  The administrator has disabled public write access.



Go to top Post Reply
Powered by FireBoardget the latest posts directly to your desktop

Blog - Forum - Privacy Policy - Contact Us
Links - Classes - Social Business - BPM - Web - General
Copyright © 2006-2013. kksou.com. All Rights Reserved