NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
PHP-GTK Problems (repost)


Joined: 16 Jun 2006
Posts: 4
Reply with quote
My last post was deleted for some reason...

Can DBG pick up changes made to variables in main() event loops? Specifically, I can't get my variables to change (even though they are changing in my code) in DBG once the main() loop kicks off. Any information at all would be great.
View user's profileFind all posts by ABuczackiSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8344
Reply with quote
DBG displays variables as is. If they are changed, it displays them changed Smile
What IDE are you using for your work?
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 16 Jun 2006
Posts: 4
Reply with quote
I'm using the trial version of PhpED. Maybe I don't have something configured properly? I've got a little sandbox program where a button toggles a variable between 0 and 1. When I click it the program functions as normal and changes the variable, but it doesn't display the change in the object window.
View user's profileFind all posts by ABuczackiSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8344
Reply with quote
Quote:
I've got a little sandbox program where a button toggles a variable between 0 and 1. When I click it the program functions as normal and changes the variable, but it doesn't display the change in the object window


Well, I'm still not sure where that object window that is expected to reflect changes.
Could you please post a sample and screenshots?
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 16 Jun 2006
Posts: 4
Reply with quote
Sure, here's the sandbox I'm using. In the lower left corner (where all the objects are hiding) it doesn't display any changes in currPage. One thing I do notice though is that the variable _does_ update if you get out of the gtk::main() loop. Unfortunately, that only happens when the program crashes or you cancel the application.


Code:
<?php

if (!extension_loaded('gtk')) {
  dl( 'php_gtk.' . PHP_SHLIB_SUFFIX);
}

class stupidobject {

  var $currPage;
  var $win;
  var $box;
  var $button;
  var $pix;
  var $tips;
  var $string1;
  var $string2;
 
  function stupidobject()
  {
    $this->currPage=0;
    $this->win = &new GtkWindow();
    $this->win->realize();
    $this->button = &new GtkButton("Toggle");
    $this->box = &new GtkHBox();
    $vbox = &new GtkVBox();
    $vbox->pack_start($this->box);
    $vbox->pack_start($this->button);
   
   
    $square = gdk::pixmap_create_from_xpm($this->win->window, null, 'C:\Documents and Settings\Administrator\Desktop\test\pic\square.xpm');
   $this->pix = &new GtkPixmap($square[0], $square[1]);
   
    $this->tips = &new GtkTooltips();
    $this->tips->set_tip($this->button, "Click me!");
   
    $startlabel = &new GtkLabel("Start");
    $this->box->pack_start($startlabel);
    $this->box->pack_start($this->pix);
    $this->button->connect("clicked", array(&$this, "toggle"));
    $this->win->add($vbox);
    $this->win->show_all();
    $this->win->connect_object("destroy", array("gtk", "main_quit"));
  }
 
  function toggle()
  {
  if($this->currPage == 1)
    {
    $this->currPage = 0;
    $this->pix->show();
    }
  else
    {$this->pix->hide();
    $this->currPage = 1;
    }
    $this->tips->set_tip($this->button, "CurrPage is now " . $this->currPage);
  }
}

$bob = &new stupidobject();
$bob->currPage = 42;

gtk::main();
?>


Last edited by ABuczacki on Mon Jun 19, 2006 2:28 pm; edited 1 time in total
View user's profileFind all posts by ABuczackiSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8344
Reply with quote
well, what's about screenshot of that object window where you're expecting the variables to change?
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 16 Jun 2006
Posts: 4
Reply with quote
I added a line after I create the object where I set currPage to 42. In the debug windows (both local and global) it recognizes the change in variable when it goes to 42, but when it hits the main() loop, the variable stays the same regardless of what currPage really is. Only after the loop does it change. I'll try to get some screenshots up now, I'll edit them into this post.

right after the object is initialized:

object initialized and currPage set to 42:

button is clicked once in the window, currPage SHOULD be 1:

button clicked again, currPage should be 0:

(subsequent clicks just toggle between the above two steps)

Assume currPage is 1, exit window (click the x in the upper right):

While I only show the Locals tab, it's the same value in the Globals tab as well.
View user's profileFind all posts by ABuczackiSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8344
Reply with quote
Ah, now I got it Smile

Thanks for the screenshots.

While IDE is in a debug sesession, it may operate in two different states. First one is when debugger waits for user action. It allows you to click all kinds of step (Step In, Step out...) Continue, Stop etc. In this state, let's call it command state, IDE waits for next command and shows you what previous command resulted with. If you, for example did step over $bob->currPage = 42, IDE will reflect changes done by this statement immediately when it enters command state.
Another state is when IDE performs your command. In this state, it only lets you press Stop to terminate debug session and press Pause to break execution on a line. In this state php performs statement(s), changes values and so forth, but no data is transmitted to the ide (or it would slow down by million times).

So... I think there is nothing wrong with IDE in your case. Just put a breakpoint on a line to see variable values on that line and continue execution until next point of interest. That's a common scenario for all interactive debuggers.

Let me know if you have any doubts Smile
View user's profileFind all posts by dmitriSend private messageVisit poster's website
PHP-GTK Problems (repost)
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic