@@ -337,14 +337,13 @@ bool GraphicsView::addComponent(QString className, QPointF position)
337337 if (isClassDroppedOnItself (pLibraryTreeItem)) {
338338 return false ;
339339 } else { // check if the model is partial
340- QString name;
341340 if (pLibraryTreeItem->isPartial ()) {
342341 if (pOptionsDialog->getNotificationsPage ()->getReplaceableIfPartialCheckBox ()->isChecked ()) {
343342 NotificationsDialog *pNotificationsDialog = new NotificationsDialog (NotificationsDialog::ReplaceableIfPartial,
344343 NotificationsDialog::InformationIcon,
345344 MainWindow::instance ());
346345 pNotificationsDialog->setNotificationLabelString (GUIMessages::getMessage (GUIMessages::MAKE_REPLACEABLE_IF_PARTIAL)
347- .arg (StringHandler::getModelicaClassType (type).toLower ()).arg (name ));
346+ .arg (StringHandler::getModelicaClassType (type).toLower ()).arg (pLibraryTreeItem-> getName () ));
348347 if (!pNotificationsDialog->exec ()) {
349348 return false ;
350349 }
@@ -354,14 +353,11 @@ bool GraphicsView::addComponent(QString className, QPointF position)
354353 QString defaultPrefix = pMainWindow->getOMCProxy ()->getDefaultComponentPrefixes (pLibraryTreeItem->getNameStructure ());
355354 // get the model defaultComponentName
356355 QString defaultName = pMainWindow->getOMCProxy ()->getDefaultComponentName (pLibraryTreeItem->getNameStructure ());
357- if (defaultName.isEmpty ()) {
358- name = getUniqueComponentName (StringHandler::toCamelCase (pLibraryTreeItem->getName ()));
356+ QString name;
357+ if (!defaultName.isEmpty () && checkComponentName (defaultName)) {
358+ name = defaultName;
359359 } else {
360- if (checkComponentName (defaultName)) {
361- name = defaultName;
362- } else {
363- name = getUniqueComponentName (defaultName);
364- }
360+ name = getUniqueComponentName (StringHandler::toCamelCase (pLibraryTreeItem->getName ()));
365361 }
366362 // Allow user to change the component name if always ask for component name settings is true.
367363 if (pOptionsDialog->getNotificationsPage ()->getAlwaysAskForDraggedComponentName ()->isChecked ()) {
0 commit comments