After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 119049 - Gdk::Display::open() ref-count problem.
Gdk::Display::open() ref-count problem.
Status: RESOLVED FIXED
Product: gtkmm
Classification: Bindings
Component: general
2.2
Other Linux
: Normal normal
: ---
Assigned To: gtkmm-forge
gtkmm-forge
Depends on:
Blocks:
 
 
Reported: 2003-08-04 00:29 UTC by sterling
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description sterling 2003-08-04 00:29:36 UTC
Basically, if I request a Gdk::Display object using the open() method, the
RefPtr returned causes an exception when the reference leaves scope. This
short program reproduces the issue on Gentoo with the latest ebuild version
(2.2.5) installed:

#include <iostream>
#include <gdkmm/display.h>
#include <gtkmm/main.h>

int main(int argc, char **argv) {
    Gtk::Main kit(argc, argv);
    std::cout << "Print this." << std::endl;
    {   
        Glib::RefPtr<Gdk::Display> display = Gdk::Display::open(":0.0");
        std::cout << "RefPtr is still good." << std::endl;
    }
    std::cout << "This will never print." << std::endl;

    return 0;
}

Compiling this against the gtkmm and gdkmm libraries will have this output:

$ g++ -o test test.cc `pkg-config --libs --cflags gdkmm-2.0 gtkmm-2.0`
$ ./test
Print this.
RefPtr is still good.
Segmentation fault

It's pretty clear where the problem is. To make it even more explicit
adding a call to display.clear() right above the "RefPtr is still good."
line will keep that from being printed.
Comment 1 Murray Cumming 2003-08-04 07:41:26 UTC
I guess we need an extra "refreturn" here:
http://cvs.gnome.org/lxr/source/gtkmm-root/gdk-src/display.hg#43

open_default() migtht need the same thing.
Comment 2 sterling 2003-08-04 15:11:58 UTC
That's probably right. I'm not familiar with gtkmm's internals, but I
ran into this on the gtkmm-list archives when looking for a solution:

http://mail.gnome.org/archives/gtkmm-list/2003-January/msg00228.html

This person was having a problem with open_default()--as I recall. And
a similar suggestion was made.
Comment 3 Murray Cumming 2003-08-05 08:05:16 UTC
A patch would be welcome. Otherwise, it will take me a week or so to
get to this.
Comment 4 Murray Cumming 2003-08-20 10:50:18 UTC
Fixed in cvs (we will make a new release soon too). Please confirm
that it works for you.