Issue with GtkFileChooser and G_IS_OBJECT warnings with GtkCellRendererCombo

I have an issue which is driving me to distraction

I have a treeview, which one of the cellrenderercombo’s calls GtkfileselectorDialog

Everything works perfectly, EXCEPT, every time I use it I get

GLib-GObject-CRITICAL **: g_object_notify: assertion ‘G_IS_OBJECT (object)’ failed at /usr/share/perl5/vendor_perl/ line 572.
GLib-GObject-CRITICAL **: g_object_set: assertion ‘G_IS_OBJECT (object)’ failed at /usr/share/perl5/vendor_perl/ line 572.

(using perl bindings as you can see)

If the cellrenderercombo has an entry (which I don’t want) there is no error, however if (‘has-entry’) ==1 I get this

It seems to be wanting an internal widget of some description

Any idea what is causing this (and how to fix it )

Any ideas appreciated

I’m sorry, I don’t understand what you’re trying to achieve. What’s a GtkFileSelectorDialog, and what does it have to do with a combo cell renderer?

You’re trying to set a property on an object that does not have it; you’re probably misusing the cell renderer API, or you’re trying to force a state that does not exist. Since you’re not pasting your code there’s not much that can be done.

You can try using GDB and export G_DEBUG=fatal-criticals in your environment, in order to get a backtrace.

Gtk3::FileChooserDialog, apologies
I am opening a FileChooserDialog on changed signal of cellrenderercombo.
As I said if it has an entry, no error, but if it doesn’t I get the warnings referred to.

You will need to create a small, self-contained test case that exhibits this behaviour; otherwise, you will need to run your application through GDB and gather a stack trace.

use warnings;
use strict;
use utf8;
use Gtk3 '-init';
my $entry=$ARGV[0];
my $window=Gtk3::Window->new('toplevel');
$window->set_default_size (1200,600);
my $displaygrid=Gtk3::Grid->new;
$displaygrid->set_column_homogeneous (0);
$displaygrid->set_row_homogeneous (0);
my @pids;

$window->signal_connect ('delete_event' => sub {
		foreach  my $pid (@pids){kill 15,$pid} Gtk3->main_quit;
$displaygrid -> show_all();
#Define Treeview
my $treemodel=Gtk3::ListStore->new('Glib::String');
my $treeview=Gtk3::TreeView->new;
my $rend=Gtk3::CellRendererCombo->new;
my $col=Gtk3::TreeViewColumn->new();
my $model=Gtk3::ListStore->new('Glib::String');

foreach my $c ('test1','test2'){
my $model1=[$treemodel,0];
$rend->signal_connect (edited => \&cell_edited, $model1);

#Signal to show behaviour

	my $filesel=Gtk3::FileChooserDialog->new('test',$window,'open','gtk-cancel' => 'cancel','gtk-ok' => 'ok');
			if ('ok' eq $filesel->run){
			my $filename = $filesel-> get_filename;
			print "\n",$filename,"\n";

#Show window stuff

my $winsize=$window->get_allocation;
my $gtk=Gtk3->main();

sub cell_edited {
	my ($cell, $path_string, $new_text, $model1) = @_;
	my ($model2,$column)=@{$model1};
	my $model;
	my $path = Gtk3::TreePath->new_from_string ($path_string);
	my $iter = $model2->get_iter ($path);
	my $iter2;
	if ($model2=~/TreeModelFilter/){
	else {
	my $gvalue = Glib::Object::Introspection::GValueWrapper->new (
		'Glib::String', $new_text);
	$model->set_value ($iter2, $column, $gvalue);
	return 1

AS Small as I can get it - passing 0 (no entry) trigers the warning, passing 1 doesnt

I can confirm the warning, and it seems to be coming from GtkComboBox being destroyed in the middle of a signal handler, so the code after the signal emission:

  g_signal_emit (combo_box, combo_box_signals[CHANGED], 0);
  g_object_notify (G_OBJECT (combo_box), "active");
  if (priv->id_column >= 0)
    g_object_notify (G_OBJECT (combo_box), "active-id");

is called on an invalid object.

I assume the double $filesel->run is a copy-paste issue, but in general this is a terrible idea to begin with. You’re creating a modal, blocking dialog on top of a combo box menu, which is modal on its own, and has its own share of grabs and side effects. You’re also doing so in the middle of the changed signal handler, preventing it from completing. Once you close the file selection dialog (which you should do regardless of the response id, otherwise it’ll never go away) the combo box menu may have gone away.

I suggest you move the creation of the file selection dialog into an idle function, to let the rest of the UI behave like it should. If I use this:

$col->get_cells()->signal_connect('changed'=>sub {
    Glib::Idle->add(sub {
        my $filesel = Gtk3::FileChooserDialog->new('test', $window, 'open', 'gtk-cancel' => 'cancel', 'gtk-ok' => 'ok');
        if ('ok' eq $filesel->run()) {
            my $filename = $filesel-> get_filename();
            print "\n",$filename,"\n";

Then I don’t get the warning.

Thanks this worked, both in the example and in my program

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.