Skip to content

Commit

Permalink
[CORRECTIVE] Fix design component bus interfaces loading from compone…
Browse files Browse the repository at this point in the history
…nt. Fixes bugs introduced in fc14c8a.
  • Loading branch information
hagantsa committed Jul 10, 2024
1 parent cd08deb commit d60a1fb
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 36 deletions.
42 changes: 27 additions & 15 deletions editors/HWDesign/HWDesignDiagram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,14 +243,14 @@ void HWDesignDiagram::updateHierComponent()
QList<QSharedPointer<BusInterface> > busIfs;

// Search all graphics items in the scene.
for (QGraphicsItem *item : items())
for (QGraphicsItem* item : items())
{
// Check if the item is a diagram interface and its bus interface is defined.
if (auto diagIf = dynamic_cast<HierarchicalBusInterfaceItem*>(item))
{
if (diagIf->getBusInterface() != nullptr && !diagIf->isInvalid())
{
busIfs.append(diagIf->getBusInterface());
busIfs.append(diagIf->getBusInterface());
}
}
}
Expand All @@ -271,26 +271,30 @@ void HWDesignDiagram::updateHierComponent()
}
}

QList<QSharedPointer<BusInterface> > toRemove;

// Remove interfaces deleted in the design from the component.
for (auto componentInterface : *componentInterfaces)
if (manuallyDeletedInterfaces_)
{
bool busExists = std::find_if(busIfs.cbegin(), busIfs.cend(), [&componentInterface](auto diagramInterface)
QList<QSharedPointer<BusInterface> > toRemove;
// Remove interfaces deleted in the design from the component.
for (auto componentInterface : *componentInterfaces)
{
bool busExists = std::find_if(busIfs.cbegin(), busIfs.cend(), [&componentInterface](auto diagramInterface)
{
return componentInterface->name() == diagramInterface->name();
}) != busIfs.cend();

if (!busExists)
{
return componentInterface->name() == diagramInterface->name();
}) != busIfs.cend();
toRemove.append(componentInterface);
}
}

if (!busExists)
for (auto interfaceToRemove : toRemove)
{
toRemove.append(componentInterface);
componentInterfaces->removeAll(interfaceToRemove);
}
}

for (auto interfaceToRemove : toRemove)
{
componentInterfaces->removeAll(interfaceToRemove);
}
manuallyDeletedInterfaces_ = false;
}

//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -410,6 +414,14 @@ HWConnectionEndpoint* HWDesignDiagram::getHierarchicalInterface(QString const& b
return nullptr;
}

//-----------------------------------------------------------------------------
// Function: HWDesignDiagram::getInterfacesToDelete()
//-----------------------------------------------------------------------------
void HWDesignDiagram::setInterfacesHaveBeenDeleted(bool haveBeenDeleted)
{
manuallyDeletedInterfaces_ = true;
}

//-----------------------------------------------------------------------------
// Function: HWDesignDiagram::onCopyAction()
//-----------------------------------------------------------------------------
Expand Down
32 changes: 21 additions & 11 deletions editors/HWDesign/HWDesignDiagram.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class HWDesignDiagram : public ComponentDesignDiagram
{
QSharedPointer<Component> component; //!< The referenced component.
QSharedPointer<ComponentInstance> instance;

ComponentInstanceCopyData()
: component(),
instance()
Expand Down Expand Up @@ -155,8 +155,8 @@ class HWDesignDiagram : public ComponentDesignDiagram
*/
ColumnCopyData()
: desc(),
components(),
interfaces()
components(),
interfaces()
{
}
};
Expand All @@ -176,7 +176,7 @@ class HWDesignDiagram : public ComponentDesignDiagram
{
}
};

/*!
* The constructor.
*
Expand All @@ -186,15 +186,15 @@ class HWDesignDiagram : public ComponentDesignDiagram
* @param [in] designParameterFinder Parameter finder for design parameters.
* @param [in] parent Owner of this diagram.
*/
HWDesignDiagram(LibraryInterface *lh, QSharedPointer<IEditProvider> editProvider,
HWDesignDiagram(LibraryInterface* lh, QSharedPointer<IEditProvider> editProvider,
QSharedPointer<MultipleParameterFinder> designAndInstancesParameterFinder,
QSharedPointer<ListParameterFinder> designParameterFinder,
DesignWidget* parent = 0);

/*!
/*!
* The destructor.
*/
~HWDesignDiagram() final = default;
~HWDesignDiagram() final = default;

/*!
* Set the IP-XACT document that is viewed in HWDesignDiagram.
Expand All @@ -206,7 +206,7 @@ class HWDesignDiagram : public ComponentDesignDiagram
*/
HWComponentItem* getComponentItem(QString const& instanceName);

/*!
/*!
* Reflects the changes in the design to the top-level component.
*/
virtual void updateHierComponent();
Expand Down Expand Up @@ -239,15 +239,22 @@ class HWDesignDiagram : public ComponentDesignDiagram
virtual HWConnectionEndpoint* getDiagramAdHocPort(QString const& portName);

/*!
* Returns the bus interface item of the corresponding design component bus interface with the given name
* Returns the bus interface item of the corresponding design component bus interface with the given name
* or nullptr if not found.
*
*
* @param [in] busRef The interface name.
*
*
* @return The hierarchical bus interface item found or null.
*/
HWConnectionEndpoint* getHierarchicalInterface(QString const& busRef) const;

/*!
* Sets the value of the flag indicating if interfaces have been deleted in the design diagram.
*
* @param [in] haveBeenDeleted Flag value to set.
*/
void setInterfacesHaveBeenDeleted(bool haveBeenDeleted);

public slots:

/*!
Expand Down Expand Up @@ -926,6 +933,9 @@ public slots:

//! Parameter finder for design parameter reference tree
QSharedPointer<MultipleParameterFinder> designAndInstancesParameterFinder_;

//! Flag indicating if interfaces have been deleted from the design diagram.
bool manuallyDeletedInterfaces_ = false;
};

#endif // HWDESIGNDIAGRAM_H
8 changes: 6 additions & 2 deletions editors/HWDesign/HWDesignWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,7 @@ void HWDesignWidget::deleteSelectedBusInterfaceItems(QList<QGraphicsItem*> selec
new InterfaceDeleteCommand(getDiagram(), diagIf, removePorts, cmd.data());
connect(childCmd, SIGNAL(interfaceDeleted()), this, SIGNAL(clearItemSelection()), Qt::UniqueConnection);

static_cast<HWDesignDiagram*>(getDiagram())->setInterfacesHaveBeenDeleted(true);
childCmd->redo();
}

Expand Down Expand Up @@ -917,14 +918,15 @@ void HWDesignWidget::loadBusInterfaceChanges(QSharedPointer<Component const> lib
designComponentInterfaces.append(compBusif);
}

// Remove deleted interfaces (aka if interface exists in design component but not in component loaded from disk)
auto hwDiagram = static_cast<HWDesignDiagram*>(getDiagram());

// Remove deleted interfaces (aka if interface exists in design component but not in component loaded from disk).
for (auto designComponentInterfaceIt = designComponentInterfaces.begin(); designComponentInterfaceIt != designComponentInterfaces.end();)
{
if (auto foundInterface = Search::findByName((*designComponentInterfaceIt)->name(), libraryComponentInterfaces);
foundInterface == nullptr)
{
// Remove connections and routes from design, if interface had no connections
auto hwDiagram = static_cast<HWDesignDiagram*>(getDiagram());
if (auto endpointItem = hwDiagram->getHierarchicalInterface((*designComponentInterfaceIt)->name()))
{
auto busItem = static_cast<HierarchicalBusInterfaceItem*>(endpointItem);
Expand All @@ -939,6 +941,8 @@ void HWDesignWidget::loadBusInterfaceChanges(QSharedPointer<Component const> lib
design->getInterconnections()->removeOne(interconnectionItem->getInterconnection());
}
}

hwDiagram->removeItem(busItem);
}

designComponentInterfaceIt = designComponentInterfaces.erase(designComponentInterfaceIt);
Expand Down
2 changes: 2 additions & 0 deletions editors/common/DesignWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ QSharedPointer<IEditProvider> DesignWidget::getEditProvider() const
//-----------------------------------------------------------------------------
bool DesignWidget::save()
{
getDiagram()->updateHierComponent();

// Create the design.
QSharedPointer<Design> design = getDiagram()->getDesign();
QSharedPointer<DesignConfiguration> designConf = getDiagram()->getDesignConfiguration();
Expand Down
16 changes: 8 additions & 8 deletions version.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@
#ifndef VERSIONNO__H
#define VERSIONNO__H

#define VERSION_FULL 3.13.484.0
#define VERSION_FULL 3.13.513.0

#define VERSION_BASEYEAR 0
#define VERSION_DATE "2024-07-08"
#define VERSION_TIME "13:18:48"
#define VERSION_DATE "2024-07-10"
#define VERSION_TIME "13:40:57"

#define VERSION_MAJOR 3
#define VERSION_MINOR 13
#define VERSION_BUILDNO 484
#define VERSION_BUILDNO 513
#define VERSION_EXTEND 0

#define VERSION_FILE 3,13,484,0
#define VERSION_PRODUCT 3,13,484,0
#define VERSION_FILESTR "3,13,484,0"
#define VERSION_PRODUCTSTR "3,13,484,0"
#define VERSION_FILE 3,13,513,0
#define VERSION_PRODUCT 3,13,513,0
#define VERSION_FILESTR "3,13,513,0"
#define VERSION_PRODUCTSTR "3,13,513,0"

#endif

0 comments on commit d60a1fb

Please sign in to comment.