Script crashing on Win32 PHP-GTK 0.5.1

From: Date: Fri, 24 May 2002 02:08:09 +0000
Subject: Script crashing on Win32 PHP-GTK 0.5.1
Groups: php.gtk.general 
Request: Send a blank email to php-gtk-general+get-2043@lists.php.net to get a copy of this message
Can anyone see if this script crashes their PHP-GTK? I get a "This memory cannot be 'read'" error with various addresses (sometimes 0xffffffff, sometimes 0x00000000, sometimes random numbers..) I'd like to think this has something to do with the timeout_add and timeout_remove functions, but I'm not sure. To repeat the crashing: Start program. Click start. If that doesn't crash, try pressing a variety of the buttons to see if it causes problems. (Sorry for the long post, but I couldn't isolate the problem very well.) <?php if (!class_exists('gtk')) { if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') dl('php_gtk.dll'); else dl('php_gtk.so'); } $g_cur_project = false; $g_timeout_id = false; $g_elapsed_secs = 0; function everySecondCB() { global $g_elapsed_label; global $g_elapsed_secs; $g_elapsed_secs++; $min = $g_elapsed_secs / 60; $secs = $g_elapsed_secs % 60; $label = sprintf("Elapsed: %d:%02d", $min, $secs); $g_elapsed_label->set_text($label); return true; } function startGTKTimer() { global $g_timeout_id; echo "Starting..\n"; //if (isset($g_timeout_id) && // $g_timeout_id !== false) { // gtk::timeout_remove($g_timeout_id); //} $g_timeout_id = gtk::timeout_add(1000, everySecondCB); } function stopGTKTimer() { global $g_timeout_id; echo "Stopping..\n"; if ($g_timeout_id !== false) { gtk::timeout_remove($g_timeout_id); $g_timeout_id = false; } } function startLogging() { startGTKTimer(); } function selectProject() { startLogging(); } function startCB() { global $g_cur_project; if ($g_cur_project === false) { // We do not yet have a project selected. Let's choose one. // selectProject() will call startLogging() on its own. selectProject(); } else { startLogging(); } } function pauseCB() { global $g_pause_button; global $g_timeout_id; global $g_pause_label; // If we're currently counting, you clicked PAUSE if (isset($g_timeout_id) && $g_timeout_id !== false) { stopGTKTimer(); // $g_pause_label->set_text("Unpause"); } // If we're not counting, you clicked UNPAUSE else { startGTKTimer(); // $g_pause_label->set_text("Pause"); } } function stopCB() { global $g_elapsed_label; global $g_timeout_id; stopGTKTimer(); } /* * Called when delete-event happens. Returns false to indicate that the event * should proceed. */ function deleteCB() { return false; } /* * Called when the window is being destroyed. Simply quit the main loop. */ function destroyCB() { Gtk::main_quit(); } $window = &new GtkWindow(); $window->connect('destroy', 'destroyCB'); $window->connect('delete-event', 'deleteCB'); $window->set_border_width(0); $g_elapsed_label = &new GtkLabel("Elapsed: 0:00"); $startButton = &new GtkButton('Start'); $startButton->connect('clicked', 'startCB'); $pauseButton = &new GtkButton(); $pauseLabel = &new GtkLabel("Pause"); $g_pause_label = &$pauseLabel; $pauseButton->connect('clicked', 'pauseCB'); $pauseButton->add($pauseLabel); $stopButton = &new GtkButton('Stop'); $stopButton->connect('clicked', 'stopCB'); $packer = &new GtkPacker(); $packer->set_default_pad(5, 5); $packer->add($g_elapsed_label, GTK_SIDE_LEFT, GTK_ANCHOR_EAST, GTK_PACK_EXPAND | GTK_FILL_X | GTK_FILL_Y, 0, 10); $packer->add($startButton, GTK_SIDE_LEFT, GTK_ANCHOR_EAST, GTK_PACK_EXPAND | GTK_FILL_X | GTK_FILL_Y); $packer->add($pauseButton, GTK_SIDE_LEFT, GTK_ANCHOR_EAST, GTK_PACK_EXPAND | GTK_FILL_X | GTK_FILL_Y); $packer->add($stopButton, GTK_SIDE_LEFT, GTK_ANCHOR_EAST, GTK_PACK_EXPAND | GTK_FILL_X | GTK_FILL_Y); $g_packer = &$packer; $window->add($packer); /* * Show the window and all its child widgets. */ $window->show_all(); /* Run the main loop. */ Gtk::main(); ?> -- thomas lackner modernmethod

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