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 94207 - TextMark::get_iter does not do a reference on Glib::RefPtr<TextMark>().
TextMark::get_iter does not do a reference on Glib::RefPtr<TextMark>().
Status: RESOLVED FIXED
Product: gtkmm
Classification: Bindings
Component: general
2.0
Other Linux
: Normal normal
: ---
Assigned To: gtkmm-forge
gtkmm-forge
Depends on:
Blocks:
 
 
Reported: 2002-09-25 20:35 UTC by mike
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch to textmark.ccg (841 bytes, patch)
2002-09-25 20:37 UTC, mike
none Details | Review
Same as previous patch. This time using requested 'cvs diff -u' command. (1.21 KB, patch)
2002-09-25 20:55 UTC, mike
none Details | Review

Description mike 2002-09-25 20:35:09 UTC
Gtk::TextMark::get_iter() does not do a reference on the
Glib::RefPtr<TextMark>(this) passed to Gtk::TextBuffer::get_iter_at_mark().
This results in the underlying GtkTextMark getting freed and subsequent seg
fault (e.g. on a second call of Gtk::TextBuffer::insert_at_cursor()).

I have attached a patch which fixes the problem although, being new to
gtkmm, perhaps the developers may have a better method of addressing the
problem.
Comment 1 mike 2002-09-25 20:37:02 UTC
Created attachment 11262 [details] [review]
Patch to textmark.ccg
Comment 2 mike 2002-09-25 20:55:14 UTC
Created attachment 11263 [details] [review]
Same as previous patch. This time using requested 'cvs diff -u' command.
Comment 3 Martin Schulze 2002-09-26 19:35:37 UTC
Shouldn't Gtk::TextBuffer::get_iter_at_mark() do the referece()? Where
does the corresponding unreference() take place?
Comment 4 mike 2002-09-26 22:11:20 UTC
You catch me a little late in the evening - so be it :-) I'm
relatively  new to C++, as well as gtkmm. That aside, reading the
documentation, doesn't the unreference() of
'Glib::RefPtr<TextMark>(this)' occur when it goes out of scope in
Gtk::TextMark::get_iter()?

I understood (maybe :-)) that Gtk::TextBuffer::get_iter_at_mark()
would normally be called with a Glib:RePtr<> that had been constructed
in such a way as to have had a 'reference()' conducted. The
constructor 'Glib::Refptr(T_CppObject* pCppObject)' as far as I can
see in refptr.h is only for use with create* methods - don't they do
their own references? 
Comment 5 mike 2002-09-26 22:25:31 UTC
Yes, it is a little late in the evening :-) WhatI meant to say was -
after construction via 'Glib::RefPtr<TextMark>(this)' - as far as I
can see no 'reference()' is conducted, but an a 'unreference()' *will*
be when it goes out of scope in 'get_iter()' - no? 
Comment 6 Murray Cumming 2002-09-27 09:51:29 UTC
That's the correct fix. Applied. It looks unusual, but that's just
because it's unusual to make a RefPtr-ed this. Remember, that this
isn't necessary outside of the class because that copy constructor is
not public anyway.