g_strdup()
- From: Ignacio Nodal <inodal teleline es>
- To: GTK-List <gtk-list gnome org>
- Subject: g_strdup()
- Date: Wed, 20 Feb 2002 13:23:08 +0000
Hi,
I'm using the g_strdup() function provided by glib, which is suppose to
duplicate a string, to update a file name string stored in a gchar* from
a GtkEntry. In fact, it's a member of a my class, so I pass it in the
constructor:
ParameterFile::ParameterFile(GtkWidget* parent, gchar* param)
{
_file_name = param;
_File_entry = 0; //It's created later
_value_changed = 0;
....
}
I've connected the "activate" signal of the GtkEntry used show/enter the
file name. In my callback I call a member function Update():
ParameterFile::Update()
{
gchar *ch;
ch = g_strdup(gtk_entry_get_text(GTK_ENTRY(_File_entry)));
_value_changed = (strcmp(_file_name, ch) != 0);
if (_value_changed) {
if (_file_name != 0) g_free(_file_name);
_file_name = g_strdup(ch);
}
}
If I call g_print("post-g_strdup %s\n",_filename); it shows me the
correct value.
If I call it in my main.cpp the value passed to the constructor, where
the strign should be stored, points whereever it my be, but not where I
want..
In my main.cpp, just testing, I use:
gchar* _wrl_name = g_strdup("default.wrl");
ParameterFile* entry_param = new ParameterFile(parent, _wrl_name);
[...]
And a button that prints _wrl_name if clicked.
What's going wrong? Can I pass _wrl_name to my constructor or do I have
to pass gchar**?
Thanks..
Someday I'll beat pointers...
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]