{
myNode = theNode;
myLastItem = 0;
- myFromItemChanged = false;
init();
}
delete theLB->item( i );
}
-void moveItem( QListBox* theLB, const int from, const int to ) {
+void SUPERVGUI_ManagePortsDlg::moveItem( QListBox* theLB, const int from, const int to ) {
if ( !theLB )
return;
+
+ // disconnect itemChanged - it leads to crash if there was only 1 item left
+ disconnect( theLB, SIGNAL(currentChanged(QListBoxItem*)), this, SLOT(itemChanged(QListBoxItem*)));
+
if ( from >= 0 && from < theLB->count() && to >=0 && to < theLB->count() ) {
QListBoxItem* item = theLB->item( from );
theLB->takeItem( item );
theLB->setCurrentItem( item );
theLB->setSelected( item, true );
}
+
+ // connect back..
+ connect( theLB, SIGNAL(currentChanged(QListBoxItem*)), this, SLOT(itemChanged(QListBoxItem*)));
}
void SUPERVGUI_ManagePortsDlg::moveUp( QListBox* theLB ) {
* the last selected by user item in myInList or myOutList (myLastItem)
*/
void SUPERVGUI_ManagePortsDlg::nameChanged( const QString& name ) {
- if ( myFromItemChanged ) return;
if ( isEditingItem( myLastItem, myInList ) || isEditingItem( myLastItem, myOutList ) ) {
((PortListItem*)myLastItem)->PortName = name;
//myLastItem->listBox()->repaint( true );
* of the last selected by user item in myInList or myOutList (myLastItem)
*/
void SUPERVGUI_ManagePortsDlg::typeChanged( const QString& type ) {
- if ( myFromItemChanged ) return;
if ( isEditingItem( myLastItem, myInList ) || isEditingItem( myLastItem, myOutList ) ) {
((PortListItem*)myLastItem)->PortType = type;
//myLastItem->listBox()->repaint( true );
* called when new item became "currentItem" in any myInList or myOutList listboxes.
*/
void SUPERVGUI_ManagePortsDlg::itemChanged( QListBoxItem * item ) {
- myFromItemChanged = true; // to disable nameChanged, typeChanged callbacks
+ if ( !item ) // after remove, etc..
+ return;
+
+ // disable nameChanged, typeChanged callbacks
+ disconnect( myNameEdt, SIGNAL(textChanged(const QString&)), this, SLOT(nameChanged(const QString&)));
+ disconnect( myTypeCombo, SIGNAL(activated(const QString&)), this, SLOT(typeChanged(const QString&)));
+
myLastItem = item;
myNameEdt->setText( ((PortListItem*)item)->PortName );
for ( int i = 0; i < myTypeCombo->count(); i++ )
myTypeCombo->setCurrentItem( i );
break;
}
- myFromItemChanged = false; // to enable nameChanged, typeChanged callbacks
+
+ // connect back nameChanged, typeChanged
+ connect( myNameEdt, SIGNAL(textChanged(const QString&)), this, SLOT(nameChanged(const QString&)));
+ connect( myTypeCombo, SIGNAL(activated(const QString&)), this, SLOT(typeChanged(const QString&)));
}