Mailinglist Archive: libyui-devel (11 mails)

< Previous Next >
[libyui-devel] Yitem and data pointer
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi
I don't knof if it is an issue or if i made a mistake but
Ytem docs says
/**
* Set the opaque data pointer for application use.
*
* Applications can use this to store the pointer to a counterpart
of this
* tree item. It is the application's responsibility to watch for
dangling
* pointers and possibliy deleting the data. All this class ever
does with
* this pointer is to store it.
**/
void setData( void * newData ) { _data = newData; }

/**
* Return the opaque data pointer.
**/
void * data() const { return _data; }

So Applications can use data pointer to manage additional information
that can be retrieved after, when the item is selected maybe.

I'm sure enough that data pointer is used by QT YTable implementation
and YTree one, and probably also in gtk. That means that data pointer
is not usable at all.

To argue that, taking as example ManyWidget code:

std::string TEST = "Test string";

YItemCollection items;
auto t = new YTreeItem( "Item 1" );

t->setData((void*)TEST.c_str());
YItem *it = t;
std::string st = (char*)it->data();
std::cout << "---------------- " << st << std::endl;

items.push_back( t );
[...]
tree->addItems( items );

st = (char*)it->data();
std::cout << "---------------- " << st << std::endl;

First cout prints correctly Test string while second one,
crashes in gtk while prints random data in qt (probaly the
QTxxxxItem implementation pointer).

So that seems to say data pointer is not for applications.

WDYT?

Cheers,
Angelo
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.14 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEARECAAYFAlLTCsEACgkQqEs9DA4DquAnmQCfUBwtCUfPbdldedySlFRBjXVV
xdYAoK301vuNdsgx89+eiKTBCxhIEiqM
=TUMj
-----END PGP SIGNATURE-----
--
To unsubscribe, e-mail: libyui-devel+unsubscribe@xxxxxxxxxxxx
To contact the owner, e-mail: libyui-devel+owner@xxxxxxxxxxxx

< Previous Next >
List Navigation
This Thread
  • No further messages