Bug 366181 - Template inserted by user isn't saved
Summary: Template inserted by user isn't saved
Status: CONFIRMED
Alias: None
Product: umbrello
Classification: Applications
Component: general (show other bugs)
Version: 2.11.2
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Umbrello Development Group
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-07-27 19:52 UTC by Lays Rodrigues
Modified: 2016-08-01 11:32 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Lays Rodrigues 2016-07-27 19:52:34 UTC
If the user type a different type for the template, that isn't in the options, this template isn't saved. The saved templates appears in the template object in the scene, but a type insert by the user don't appear.

Reproducible: Always

Steps to Reproduce:
1.Create A class
2.Add a Template
3. Insert a new type
4. Press Ok


Actual Results:  
The new type doesn't appear be saved and doesn't appear on the scene

Expected Results:  
The type appear and is saved in the UmlObject
Comment 1 Ralf Habacker 2016-07-28 18:04:41 UTC
The oldest umbrello version I currently have access to shows also this bug, which is 2.15.3.
Comment 2 Ralf Habacker 2016-08-01 07:50:55 UTC
Bug is also present in older versions like 2.11.2.
Comment 3 Ralf Habacker 2016-08-01 11:09:37 UTC
This problem does not occur on using a pointer as data type e.g. test1234*.
Comment 4 Ralf Habacker 2016-08-01 11:32:59 UTC
Classifier widget and tree view requires to have an UMLTemplate class instance for showing the template datatype.  The recent code has two bugs, which prevents adding of non pointer and non common data types as template datatype.

In bool UMLDatatypeWidget::applyTemplate(), which got the data type related part of  UMLTemplateDialog::apply() there is the following code:

    QString typeName = m_datatypeWidget->currentText();
    UMLDoc *pDoc = UMLApp::app()->document();
    UMLClassifierList namesList(pDoc->concepts());
* get all  objects from logical root with type Class, Interface,  Datatype, Enum, Entity, Package, Folder
    foreach (UMLClassifier* obj, namesList) {
        if (typeName == obj->name()) {
*  here a related classifier has been found and is set as template type. 
            m_pTemplate->setType(obj);
* because it does not return with TRUE the last occurence of the related type is used 
        }
    }
* only if no global objects has been found  (which is never the case) the template type name is used. 
    if (namesList.isEmpty()) { // not found.
        // FIXME: This implementation is not good yet.
        m_pTemplate->setTypeName(typeName);
    }

The second bug is located in UMLClassifierListItem::setTypeName(), which in the recent state adds such an instance only for common data and pointer types [1], not for classes.

void UMLClassifierListItem::setTypeName(const QString &type)
{
    if (type.isEmpty() || type == QLatin1String("void")) {
        m_pSecondary = NULL;
        m_SecondaryId.clear();
        return;
    }
    UMLDoc *pDoc = UMLApp::app()->document();
    m_pSecondary = pDoc->findUMLObject(type);
    if (m_pSecondary == NULL) {
        // Make data type for easily identified cases
[1]     if (Model_Utils::isCommonDataType(type) || type.contains(QLatin1Char('*'))) {
            m_pSecondary = Object_Factory::createUMLObject(UMLObject::ot_Datatype, type);
            uDebug() << "created datatype for " << type;
        } else {
            m_SecondaryId = type;
        }
    }
    UMLObject::emitModified();
}
 
In all other cases it sets m_secondaryID with the template datatype as text, which is not displayed in the tree view and classifier widget and not fetched on initial setup of  UMLDataTypeWidget. 

/**
 * Overrides method from UMLClassifierListItem.
 * Returns the type name of the UMLTemplate.
 * If the template parameter is a class, there is no separate
 * type object. In this case, getTypeName() returns "class".
 *
 * @return  The type name of the UMLClassifierListItem.
 */
QString UMLTemplate::getTypeName() const
{
    if (m_pSecondary == NULL)
        return QLatin1String("class");
     return m_pSecondary->name();
}