Re: Glib::wrap with copy=true semantics?
- From: Philip Langdale <plangdale vmware com>
- To: Murray Cumming <murrayc murrayc com>
- Cc: gtkmm-list mail gnome org
- Subject: Re: Glib::wrap with copy=true semantics?
- Date: Fri, 04 Mar 2005 09:53:32 -0800
Murray Cumming wrote:
Also, in gtkmm, I don't think we ever do an extra refcount on
GtkAdjustments. We only do this in combination with Glib::RefPtr<>,
which we don't use with GtkObjects. Without Glib::RefPtr<> there is no
way to unref it again.
I have attached a test case.
Thanks,
--phil
#include <gtk/gtkadjustment.h>
#include <gtkmm/adjustment.h>
#include <gtkmm/main.h>
#include <iostream>
int main(int argc, char *argv[])
{
Gtk::Main app(argc, argv);
GtkObject *adjustment = gtk_adjustment_new(0, 0, 0, 0, 0, 0);
g_object_ref(G_OBJECT(adjustment));
gtk_object_sink(adjustment);
// Ref Count is 1.
Gtk::Adjustment *wrapper = Glib::wrap(GTK_ADJUSTMENT(adjustment), true);
// Ref Count is 2, as expected.
delete wrapper;
// Ref Count is still 2; expecting 1.
g_object_unref(G_OBJECT(adjustment));
// Ref Count is 1; expecting 0.
std::cout << "Ref count is " << G_OBJECT(adjustment)->ref_count << std::endl;
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]