gvim produces error when hitting the close window

Everytime I close a gvim window with the little x on the window or Alt + F4. I get the following error and have to hit return to get my command prompt back. Has anyone seen this?

(gvim:26639): GLib-GObject-WARNING **: cannot retrieve class for invalid (unclassed) type `<invalid>'

Solution 1:

vim-gnome has this problem, but vim-gtk does not, so this is a quick fix for the problem:

sudo apt remove vim-gnome
sudo apt install vim-gtk

Solution 2:

Normally, GLib-GObject-WARNING while running gtk applications in the command line, are normally ignored by developers and demonstrate a poorly written applications. If you report a bug against the package, it would be the best, but don't act surprised if developers ignore or say that "is ok" in your bug report.

TL;dr: They are normally safe to be ignored.

Solution 3:

I found myself caught between the spurious Warning (vim-gnome) or an empty file bug with vim-gtk3. Open an existing file, then try switching to a new file that doesn't exist using

:e newEmptyFile => SEGV

So I'm back to using vim-gnome with this hack in my ~/.bash_aliases to shutup vim-gnome:

alias gvim='gvim 2>/dev/null'

I'm sure it will get fixed soon and I won't have to keep throwing away all errors because of a persistent spurious warning.