diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/render_passes.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/render_passes.cpp index a77161c34..51dc25a51 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/render_passes.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/render_passes.cpp @@ -84,6 +84,19 @@ namespace MaterialEditor connect( downButton, SIGNAL( clicked( bool ) ), this, SLOT( onDownClicked() ) ); } + bool RenderPassesWidget::passExists( const QString &label ) + { + int c = listWidget->count(); + + for( int i = 0; i < c; i++ ) + { + if( label == listWidget->item( i )->text() ) + return true; + } + + return false; + } + void RenderPassesWidget::onOKClicked() { close(); @@ -101,17 +114,7 @@ namespace MaterialEditor if( label.isEmpty() ) return; - int i = 0; - while( i < listWidget->count() ) - { - QListWidgetItem *item = listWidget->item( i ); - QString text = item->text(); - if( text == label ) - break; - i++; - } - - if( i < listWidget->count() ) + if( passExists( label ) ) { QMessageBox::warning( NULL, @@ -168,6 +171,19 @@ namespace MaterialEditor if( to.isEmpty() ) return; + if( from == to ) + return; + + if( passExists( to ) ) + { + QMessageBox::warning( + NULL, + tr( "Pass label" ), + tr( "Pass label already exists!" ) + ); + return; + } + item->setText( to ); CNelMaterialProxy material = nl3dIface->getMaterial(); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/render_passes.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/render_passes.h index 4388b2cd5..e4d4666f3 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/render_passes.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/render_passes.h @@ -40,6 +40,7 @@ namespace MaterialEditor private: void setupConnections(); + bool passExists( const QString &label ); CNel3DInterface *nl3dIface; CMaterialObserver *observer;