How to use Glib::Value?
- From: p sun fun gmail com
- To: gtkmm-list <gtkmm-list gnome org>
- Subject: How to use Glib::Value?
- Date: Mon, 04 Mar 2019 07:05:30 -0600
Hi,
Have this code
```
Glib::Value<int> datai;
datai.init(G_TYPE_INT);
datai.set(8);
std::cout << "Value = " << datai.get() << std::endl;
```
I see in stdout:
Value = 8
Works good. Now I would like to use another type: Glib::DateTime
```
Glib::Value<Glib::DateTime> data;
data.init(G_TYPE_DATE_TIME);
Glib::DateTime ctime = Glib::DateTime::create_now_utc();
data.set(ctime);
```
This compiles ok, but generates
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7b2405c in Glib::DateTime::operator= (this=0x0, src=...) at
/home/pavlo/jhbuild/checkout/glibmm-2.4/glib/glibmm/datetime.cc:89
89 if(gobject_)
Part from dbg:
```
26 Glib::Value<Glib::DateTime> data;
(gdb)
28 data.init(G_TYPE_DATE_TIME);
(gdb) p data
$1 = {<Glib::ValueBase_Boxed> = {<Glib::ValueBase> = {gobject_ =
{g_type = 0, data = {{v_int = 0, v_uint = 0, v_long = 0, v_ulong = 0,
v_int64 = 0,
v_uint64 = 0, v_float = 0, v_double = 0, v_pointer = 0x0},
{v_int = 0, v_uint = 0, v_long = 0, v_ulong = 0, v_int64 = 0, v_uint64
= 0,
v_float = 0, v_double = 0, v_pointer = 0x0}}}}, <No data
fields>}, static custom_type_ = <optimized out>}
(gdb) n
29 Glib::DateTime ctime = Glib::DateTime::create_now_utc();
(gdb) p data
$2 = {<Glib::ValueBase_Boxed> = {<Glib::ValueBase> = {gobject_ =
{g_type = 93824992400576, data = {{v_int = 0, v_uint = 0, v_long = 0,
v_ulong = 0,
v_int64 = 0, v_uint64 = 0, v_float = 0, v_double = 0,
v_pointer = 0x0}, {v_int = 0, v_uint = 0, v_long = 0, v_ulong = 0,
v_int64 = 0,
v_uint64 = 0, v_float = 0, v_double = 0, v_pointer =
0x0}}}}, <No data fields>}, static custom_type_ = <optimized out>}
(gdb) n
30 data.set(ctime);
(gdb) p data
$3 = {<Glib::ValueBase_Boxed> = {<Glib::ValueBase> = {gobject_ =
{g_type = 93824992400576, data = {{v_int = 0, v_uint = 0, v_long = 0,
v_ulong = 0,
v_int64 = 0, v_uint64 = 0, v_float = 0, v_double = 0,
v_pointer = 0x0}, {v_int = 0, v_uint = 0, v_long = 0, v_ulong = 0,
v_int64 = 0,
v_uint64 = 0, v_float = 0, v_double = 0, v_pointer =
0x0}}}}, <No data fields>}, static custom_type_ = <optimized out>}
(gdb) p ctime
$4 = {gobject_ = 0x55555557c4a0}
(gdb) n
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7b2405c in Glib::DateTime::operator= (this=0x0, src=...) at
/home/pavlo/jhbuild/checkout/glibmm-2.4/glib/glibmm/datetime.cc:89
89 if(gobject_)
(gdb)
```
Could you please help me to understand how to use Glib::Value<T> with
types such as Glib::DateTime?
Thanks.
--
- Pavlo Solntsev
---------------------------------------------
Please avoid sending me Word or PowerPoint attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html
Sent from Evolution on GNU/Debian <www.debian.org>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]