-
-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PHP randomly crashes on filling TreeView #169
Comments
Hey Nijhuis, sorry for delay Can you provide all code? what are calling I imagine the problem is the 0 on GtkTreeViewColumn, always do ZERO will cause a memory problem, but I can only confirm if I can reproduce the problem What package are you running? appimage? windows? |
I am running on Windows 11, using php-gtk3-x86_64-0.16-beta-windows. This code is a port from PHP5.6 and GTK2. The folowing glade file (MainApp.glade) gets loaded: I have a PHP called GladeBase, that is used to build the screens from the gladefile above. class GladeBase {
} ?>` Next I have a per-screen class that extends de GladeBase class, this runs the per-screen based code. Currently only working with one screen until I can get it to run stable.
?> Function TreeView_Fill, simplified for testing purposes: ` Finaly I have a base file that starts the whole program: define("DEVELOPMENT", true); include("class.GladeBase.php"); Gtk::init(); $mainapp = new MainApp(); Gtk::main(); ?>` |
I see that pasting code in the comment section messes things up. If you have a e-mail address I can send the files to you. |
you can send me all working code / files into scorninpc at google mail Did you recreate the glade file or are you using the same of Gtk2? Look that Glade does not have full compatibility between versions |
Thanks, I will send you the files. I have rebuild the glade file with Glade User Interface Designer 3.40. |
I see, thank you But i cannot find |
My bad, had the names mixed up when cleaning up the files. This has to be treeview_Statistieken in class.MainApp.php. |
This doesnt look like a PHP error, what is the exact problem here? |
but this is the error that you are facing? because look: <?php
Gtk::init();
$builder = \GtkBuilder::new_from_file("./MainApp.glade");
$builder->get_object("MainApp")->show();
$trv = $builder->get_object("treeview_Statistieken");
$column1 = new GtkTreeViewColumn("Name", new GtkCellRendererText(), "text", 0);
$trv->append_column($column1);
$model = new GtkListStore(GObject::TYPE_STRING);
$trv->set_model($model);
$builder->get_object("MainApp")->show_all();
Gtk::main(); works fine. I think you are refering Anyway, your problem are when you It's dificulte to parse your code to find the problem, sorry |
I dont know if that is the error I am facing, how can I get that debug info? I dont get any error messages, PHP just quits without any error message. It also dont quits every time, it crashes at random starts. I just get this output and then it quits: The code you are running is by far not the same as my code, but even the code below crashes at random starts. `<?php Gtk::init(); $builder = \GtkBuilder::new_from_file("./MainApp.glade"); $builder->get_object("MainApp")->show(); $builder->get_object("textview_overlay")->set_visible(0); $trv = $builder->get_object("treeview_Statistieken"); $column1 = new GtkTreeViewColumn("Name", new GtkCellRendererText(), "text", 0); $model = new GtkListStore(GObject::TYPE_STRING); Gtk::main();` Thanks for you help! |
debug are on by default, the prove is that you are getting warning of themes. Your code not crashing, it's exiting ... |
Well the result is the same, it is stopping for an unknown reason at random. Every 4 to 5 starts it is stopping when it is not supposed to. Any ideas how to debug this? |
this is random crashing before set model? Sorry but you cannot debug glade iinternals =/ My best try was rewrite a simplest code and see if this work |
Dit some more testing with code below. When it quits/crashes it gets to L21, but neither the widget "textview_overlay" is hidden, nor is widget "treeview_Statistieken" filled. It looks like when it hits Gtk::main() it just quits in stead of keeping the script running.
Output;
|
first, if you are adding the first column, you need to pass 0, not 1 change another common error, is show window at start. Gtk cannot propagate this event if something change. Preffer show_all() before main(); I dont know if it's will help, but if I change the GtkFixed to a GtkBox, all appear to works fine I'll do some more tests with GtkFixed |
I do a new Glade with the same php script, and all works fine Try my glade file test1.zip |
First: You are right, I am passing a 0 to the GtkTreeViewColumn, the 1 was suggested before so I tried this as well. This didnt affect the problems I experience. Second: I cant really use show_all, as I have glade files where certain elements are hidden by default. Show all will make them visible. Since I have over 100 glade files, with aprox over 1000 hidden elements this is not really something I would prefer. Third: I will do some extra tests as well. Fourth: I have done some testing with your Glade and PHP file, this does crash/quits as well every once in a while. Using show_all() in stead of show() does not make a difference for me. If it crashes it will show the window, with the widgets and the treeview filled. It shows the windows-loading-mouse-icon for a few seconds an then it just quits. |
I understand about visibility, I didn't imagine that would be the case @subabrain my man, can I ask you a favor? can you try run this test on windows machine? test1.zip as i cannot reproduce the problem? maybe this is a windows problem |
Just to be clear, I ran the following code. In all four combinations:
|
@Nijhuis can you do one more test for me? <?php
echo "L:" . __LINE__ . "\n";
Gtk::init();
echo "L:" . __LINE__ . "\n";
$builder = \GtkBuilder::new_from_file("./include/glade/main.glade");
echo "L:" . __LINE__ . "\n";
#$builder->get_object("MainApp")->show();
echo "L:" . __LINE__ . "\n";
#$builder->get_object("textview_overlay")->set_visible(0);
echo "L:" . __LINE__ . "\n";
/**
* does not use treevew of glade,
*/
// $trv = $builder->get_object("treeview_Statistieken");
$trv = new GtkTreeView();
$builder->get_object("scrolledwindow1")->add($trv);
echo "L:" . __LINE__ . "\n";
$column1 = new GtkTreeViewColumn("Name", new GtkCellRendererText(), "text", 0);
echo "L:" . __LINE__ . "\n";
$trv->append_column($column1);
echo "L:" . __LINE__ . "\n";
$model = new GtkListStore(GObject::TYPE_STRING);
echo "L:" . __LINE__ . "\n";
$trv->set_model($model);
echo "L:" . __LINE__ . "\n";
$builder->get_object("MainApp")->show_all();
echo "L:" . __LINE__ . "\n";
Gtk::main();
echo "L:" . __LINE__ . "\n"; I'm discarding Treeview for glade, and creating a new one, and adding inside the scrolledwindow |
After deleting treeview_Statistieken from main.glade it seems like this code is working just fine. Could not get it to crash up until now. |
as i suspected. it seems glade bind doesn't work well with many correlated sub items, as we can see on gtktreeview (treeview, columns, coluns renderes, models, etc etc) i done the test creating columns and model inside glade, and appear to be fine too i'll make some more tests to see if i can help a little more |
Having more problems with treeviews. For every record added to the treeview I use $column->set_cell_data_func($cellRenderer, "Treeview_SetCellFormat", $colKey);
But code above doesnt work, because of the two $renderer->set_property calls, when I run just one of those (either one) it works. |
Yes sort of, in my code every even row gets one color and every odd row gets another. That part works. But when I try to set the second property it just quits. Setting just one (doesnt matter which) works fine. Please try this code, for me it only shows 2 entries.
|
send me your glade file here please By your picture, your treeview does not have scroll and you have a error on |
It is the same gladefile as posted november 18th. But you where right, they get shown correctly, there just was no scrollbar visible. My problems are way more random. These small glade files and scripts seem to be running stable, and if it quits it always quits at the same point. Unfortunately this dont seem to be the case with larger scripts. It seems to me as if GTK is just to unstable when running larger pieces of code/glade files. One moment the code runs just fine, the next moment (without editing any code) it just randomly quits at some point. Will keep testing some more. |
We don't do any data analysis or processing. If you look at C code, we are just getting parameters and passing them to C functions. So small or big code doesn't matter.
This is the main problem: we start the project without verifying if params or data type are correct (this is why this project is in dev stage yet) . So sometimes you pass a wrong type or forgot some param, and it's work but with a bad GTK memory alocation. This is the main cause of crashs. As you are porting a large project, some params changed and someother dont exists anymore, so port Gtk2 to Gtk3 is not a easy piece like "try and run" |
I understand this is still in development, but what I dont understand is when I am running the exact same code ten times, I have about 4 to 6 different outcomes. If a parameter is missing, or of the wrong datatype, this should result in the same outcome everytime. Right? |
No, sometimes memory is alocated with random value or alocated with old value of the memory in this space. Sometimes works, sometimes works wrong, sometimes break. Memory is a pain when we work with c/cpp |
When trying to filling a TreeView with code below, CLI just randomly crashes somtimes, while other times it will execute the code as intended.
Sometimes the code gets to b, sometimes to c, sometimes to d. There is no logic behind this and no errors to debug.
The text was updated successfully, but these errors were encountered: