php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #25516 Gtk Widgets cannot be stored in Object Variables
Submitted: 2003-09-12 10:14 UTC Modified: 2006-07-13 16:36 UTC
Votes:3
Avg. Score:3.0 ± 1.6
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: auroraeosrose at hotmail dot com Assigned:
Status: Closed Package: PHP-GTK related
PHP Version: 1.0.0 OS: Win XP Pro SP1
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: auroraeosrose at hotmail dot com
New email:
PHP Version: OS:

 

 [2003-09-12 10:14 UTC] auroraeosrose at hotmail dot com
Description:
------------
I went to the mailing list first to make sure I wasn't losing my mind and they assured me I'm supposed to be able to store a widget in an object variable.  I'm using builds from http://kromann.info for php5 and php-gtk for php5

The code I'm using is very simple - it's just supposed to show a window.  The class is below - very basic.  Here's the deal - when use $this->window inside the newWindow method nothing happens.  The script runs, I guess, and that's the end of it.

It seems to be impossible to assign a php-gtk widget to an object variable, which is really, really annoying

Reproduce code:
---------------
<?php
dl('php_gtk.dll');

$class = new Window();
$window = $class->newWindow('main', 'Product :: Title Here');
$window->connect('destroy', 'destroy');
$window->connect('delete-event', 'delete');
$window->show_all();
Gtk::main();

 function delete()
 {
  return FALSE;
 }

 function destroy()
 {
  GTK::main_quit();
 }

class Window
{
 var $window;

function newWindow($name, $title, $type = GTK_WINDOW_TOPLEVEL, $width =
NULL, $height = NULL, $position = GTK_WIN_POS_CENTER)
{
 //find height and width
 if(is_null($width))
 {
  $width = gdk::screen_width()-50;
 }
 if(is_null($height))
 {
  $height = gdk::screen_height()-100;
 }
 //create the window
 $this->window = new GtkWindow($type);
 $this->window->set_name($name);
 $this->window->set_title($title);
 $this->window->set_default_size($width, $height);
 $this->window->set_position($position);
 return $this->window;
}
}
?>

Expected result:
----------------
A window should appear

Actual result:
--------------
Nothing happens, no errors, the script just kind of acts like it was run and closed.

Here's some more weirdness - php seems to be dying completely (and silently) on

$this->window = new GtkWindow($type);

because I can't echo or print_r or var_dump anything after that call, while before I can just fine, and I'm not getting any errors.


And if I change every occurence of $this->window to just $window and try to do a var_dump, nothing is printed but the window appears.  If I do a print_r on $window
I get GtkWindow Object - and the window appears properly - so the problem is with the object variable.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-09-12 23:33 UTC] alan_k@php.net
can you follow php4 conventsions and use aliasing? 
$class = &new Window();
$this->window = &new GtkWindow($type);

does it work ok then?

There is a BC flag in php.ini that is supposed to turn off/on object cloning.. - is that set?
 [2003-09-15 07:31 UTC] auroraeosrose at hotmail dot com
Although I can't find the directive in the php.ini I'm using, implicit clone is off if you check phpinfo();  But that would only matter if I were trying to copy an object, e.g. $window =  new GtkWindow(); $newwindow = $window; ...but I'm not doing any of that, I'm just trying to assign a gtk widget to an object variable

Aliasing does absolutely nothing - problem still exists
 [2003-10-03 21:38 UTC] alan_k@php.net
I think without a final 'release' version or some ability to debug on XP  it will be imposible to diagnose or fix this.

Suspending until PHP5 & PHP-GTK are actually released.

You may just try removing all the PHP & PHP-GTK binaries and update from the latest snapshots.
 [2006-07-13 16:36 UTC] auroraeosrose at hotmail dot com
Fixed in current CVS
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Oct 05 18:01:28 2024 UTC