You are not logged in.

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Saturday, December 11th 2010, 9:54am

Plasmoid Crashes

Hey guys,

I'm currently extending the currentApp plasmoid. So this plasmoid has a simple construct such as

Source code

1
QHash<QGraphicsLinearLayout*, WId> m_windows;


The hashtable gets filled with

Source code

1
2
3
4
5
6
7
8
9
10
11
 QGraphicsLinearLayout *listLayout = new QGraphicsLinearLayout(m_layout);
            	listLayout->setOrientation(Qt::Horizontal);

            	Plasma::IconWidget *closeWindow = new Plasma::IconWidget(m_listWidget);
            	closeWindow->setSvg("widgets/configuration-icons", "close");
            	closeWindow->setMaximumWidth(KIconLoader::SizeSmallMedium);

            	icon = new Plasma::IconWidget(m_listWidget);
            	
            	// fill the hashtable
            	m_windows[listLayout] = //some window ID


When I wanted to access the Hashtable once, no problem, however when I want to access the Hashtable a sencond time (which means

Source code

1
KWindowSystem::forceActiveWindow(/* some value of the hashtable */);

was called) my application chrashes every time I want to access members of the key.

BTW: In this code snippet I also could've used hashtable.contains(..), but this one underneath is a workaround.

Source code

1
2
3
4
5
6
7
8
9
10
11
12
QHash<QGraphicsLinearLayout*, WId>::const_iterator i = m_item.constBegin();
    	while (i != m_item.constEnd())
    	{
        	Plasma::IconWidget *w = static_cast<Plasma::IconWidget*>(sender());
        	QGraphicsLinearLayout *li = static_cast<QGraphicsLinearLayout *>(i.key());
        	
          	// check for containment
          	if (w == li->itemAt(0)->graphicsItem()) // application crashes here
          	{
             	KWindowSystem::forceActiveWindow(i.value());
          	}
       	}


Thank you in advance

bests