Lazarus

Programming => Widgetset => GTK => Topic started by: howardpc on November 04, 2018, 06:51:31 pm

Title: Gtk-CRITICAL **: gtk_window_realize_icon: assertion 'info->icon_pixmap == NULL'
Post by: howardpc on November 04, 2018, 06:51:31 pm
I successfully create a modal dialog form which serves my purpose, and closes without any memory leak.
However, on closing the dialog, I receive the error shown in the subject.
Does anyone know what could cause this, and how to avoid it?
Title: Re: Gtk-CRITICAL **: gtk_window_realize_icon: assertion 'info->icon_pixmap == NULL'
Post by: lucamar on November 04, 2018, 07:59:27 pm
Are there any icons/images in your form? That error usually means that GTK is trying to draw something that isn't there.

ETA: Note that it *can* be the form's icon, though it's ... unusual, to say the least.
Title: Re: Gtk-CRITICAL **: gtk_window_realize_icon: assertion 'info->icon_pixmap == NULL'
Post by: howardpc on November 04, 2018, 10:02:55 pm
It is happening in what is basically a text-only dialog.
The only icons are a system close icon (drawn, I suppose, by internal LCL code, in the non-client area) since  the BorderStyle is bsDialog.
There are also stock icons on the Cancel and OK bitbuttons... again drawn by internal LCL code.
Could this be an LCL bug?
Title: Re: Gtk-CRITICAL **: gtk_window_realize_icon: assertion 'info->icon_pixmap == NULL'
Post by: lucamar on November 04, 2018, 11:47:21 pm
I haven't been able to reproduce it with any of my dialogs--Lazarus 1.8.4/3.0.4 - Kubuntu 14.04.

From what I have seen out there this is a rare error: I have been able to find only some (rather old and C) references for wxWidgets. Can you share your configuration and some (failing) example code?
Title: Re: Gtk-CRITICAL **: gtk_window_realize_icon: assertion 'info->icon_pixmap == NULL'
Post by: howardpc on November 05, 2018, 12:03:38 am
See attached project.
The GTK error happens on Mint 18.3, 64-bit.
Laz 2.1.0 r59165M
Title: Re: Gtk-CRITICAL **: gtk_window_realize_icon: assertion 'info->icon_pixmap == NULL'
Post by: lucamar on November 05, 2018, 01:10:39 am
Works OK here, though I had to delete DoubleBuffered and ParentDoubleBuffered from udlgform.lfm.

There is one potential problem in function GetUserResponsesDlgOK(): the dialog is never destroyed. Although it's a local var and, supposedly, freed on exit you should either make sure of it:

Code: Pascal  [Select][+][-]
  1. function GetUserResponsesDlgOK(const aCaption, aHeading: String;
  2.   aPrompts: TAnsiStringArray; out UserTexts: TAnsiStringArray;
  3.   anEditWidth: Integer): Boolean;
  4. var
  5.   dlg: TDialogForm;
  6.   i: Integer;
  7. begin
  8.   dlg := TDialogForm.Create(aCaption, aHeading, aPrompts, anEditWidth);
  9.   try
  10.     Result := dlg.ShowModal = mrOK;
  11.     case Result of
  12.       [. . . etc . . .]
  13.     end;
  14.   finally
  15.     dlg.Free;
  16.   end;
  17. end;

or use a global variable--kind of a singleton--in the implementation part. But then you'd have to take control initialization out of Create or, at least, add setters for the captions.

There are some other things (p.e. I wouldn't assume the owner to be Application) and all in all I wouldn't have done it like that but there doesn't seem to be any place to point to and say: "here's where it fails" so there may in fact be some bug in Lazarus 2.1 that isn't present in previous versions.

Sorry to not be able to help more.
Title: Re: Gtk-CRITICAL **: gtk_window_realize_icon: assertion 'info->icon_pixmap == NULL'
Post by: howardpc on November 05, 2018, 09:52:26 am
Quote
Works OK here, though I had to delete DoubleBuffered and ParentDoubleBuffered from udlgform.lfm.
Do you mean it does not produce the gtk error using an earlier versions of Lazarus?
DoubleBuffered is just there for use on Windows. AFAIK it has no effect on Linux.
Quote
the dialog is never destroyed
It is never destroyed in the function call code, true. But Application is explicitly made the Owner in the inherited constructor (it is not assumed), so other LCL code takes care of freeing the dialog and its controls.
Thanks for taking the time to investigate.
Title: Re: Gtk-CRITICAL **: gtk_window_realize_icon: assertion 'info->icon_pixmap == NULL'
Post by: lucamar on November 05, 2018, 11:00:17 am
Do you mean it does not produce the gtk error using an earlier versions of Lazarus?
DoubleBuffered is just there for use on Windows. AFAIK it has no effect on Linux.

No, it doesn't produce the error. And remember that I'm using Lazarus 1.8.4; it chokes on the DoubleBuffered properties.

Quote
It is never destroyed in the function call code, true. But Application is explicitly made the Owner in the inherited constructor (it is not assumed), so other LCL code takes care of freeing the dialog and its controls.

Yes, but if you free it when done you waste less memory. Just a question of tastes, I guess :)
Title: Re: Gtk-CRITICAL **: gtk_window_realize_icon: assertion 'info->icon_pixmap == NULL'
Post by: howardpc on November 05, 2018, 10:03:35 pm
I stripped it down to a do-nothing dialog project which still shows the issue with Laz 2.1.0 and submitted a bug report.
Title: Re: Gtk-CRITICAL **: gtk_window_realize_icon: assertion 'info->icon_pixmap == NULL'
Post by: dbannon on November 05, 2018, 11:55:32 pm
Code: Pascal  [Select][+][-]
  1. (tomboy-ng:3323): Gtk-CRITICAL **: 09:48:59.879: gtk_window_realize_icon: assertion 'info->icon_pixmap == NULL' failed

Hmm, I'm afraid I can reproduce it in a 1.8.4 install Howard.

Only in a specific case where I am opening a window that dos not normally produce that error message. Your post prompted my memory and I went looking.  I'll see if I can track down where it happens.....

Davo
Title: Re: Gtk-CRITICAL **: gtk_window_realize_icon: assertion 'info->icon_pixmap == NULL'
Post by: dbannon on November 06, 2018, 12:40:32 am
OK, I doubt what I am seeing has any relation to your problem Howard.

In my case, its when I open up a KMemo component, do a dummy paste (see below) and KMemo, eventually tickles line 7451 of gtk2proc.inc. 

Code: Pascal  [Select][+][-]
  1. if gtk_selection_convert(ClipboardWidget, ClipboardTypeAtoms[ClipboardType], FormatID, TimeID)<>GdkFalse

This is far from a bare form ! And note there are no icons or pixmaps of any kind associated in any way with generating this warning. Its a paste operation.

"Dummy paste" -  :-[  :-[ I found that Kmemo would loose its first paste sometimes. So, during setup, I do a dummy paste, I'm going to clear it any way so it does no harm. But, as noted it appears to trigger that GTK warning in one specific instance of my app, not in normal use. So, I guess I need to try and find out whats different in this specific use. Sigh ....

The code it here, it happens in single note mode only in Linux (obviously!) but I really don't think its at all relevant to your issue.
https://github.com/tomboy-notes/tomboy-ng

Davo
TinyPortal © 2005-2018