Skip to content

Commit

Permalink
[CORRECTIVE] Fix memory map visualization not showing overlap errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
hagantsa committed Dec 7, 2023
1 parent 111bde9 commit cf9c726
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 32 deletions.
51 changes: 27 additions & 24 deletions editors/ComponentEditor/visualization/memoryvisualizationitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,36 +240,39 @@ void MemoryVisualizationItem::fillGapsBetweenChildren()
// Function: MemoryVisualizationItem::markConflictingChildren()
//-----------------------------------------------------------------------------
void MemoryVisualizationItem::markConflictingChildren()
{
const auto offset = getOffset();
const auto lastAddress = getLastAddress();

quint64 highestAddressInUse = offset;

{
for (auto child = childItems_.begin(); child != childItems_.end(); ++child)
{
if (auto& current = child.value(); current->isPresent())
{
auto const& currentOffset = child.key();
markChildIfConflicting(child.value());
}
}

//-----------------------------------------------------------------------------
// Function: MemoryVisualizationItem::markChildIfConflicting()
//-----------------------------------------------------------------------------
void MemoryVisualizationItem::markChildIfConflicting(MemoryVisualizationItem* child)
{
if (!child || !child->isPresent())
{
return;
}

bool overlaps = currentOffset > offset && currentOffset <= highestAddressInUse;
bool isOutsideBounds = currentOffset < offset || current->getLastAddress() > lastAddress;
auto parentOffset = getOffset();
auto lastAddress = getLastAddress();

current->setConflicted(overlaps || isOutsideBounds);
auto const& currentChildOffset = child->getOffset();

if (overlaps)
{
// Mark any overlapping items conflicted.
for (auto preceding = childItems_.begin(); preceding != child; ++preceding)
{
if ((*preceding)->getLastAddress() >= currentOffset)
{
(*preceding)->setConflicted(true);
}
}
}
bool isOutsideBounds = currentChildOffset < parentOffset || child->getLastAddress() > lastAddress;

child->setConflicted(isOutsideBounds);

highestAddressInUse = qMax(current->getLastAddress(), highestAddressInUse);
// Check overlap with preceding children. Mark any overlapping items conflicted.
for (auto precedingChild = childItems_.begin(); precedingChild.value() != child; ++precedingChild)
{
if ((*precedingChild)->getLastAddress() >= currentChildOffset)
{
(*precedingChild)->setConflicted(true);
child->setConflicted(true);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ protected slots:

//! Mark all invalid children outside item boundaries.
virtual void markConflictingChildren();

//! Handler for mouse press events
virtual void mousePressEvent(QGraphicsSceneMouseEvent* event);

Expand All @@ -182,6 +182,13 @@ protected slots:
*/
bool emptySpaceBeforeChild(MemoryVisualizationItem const* current, quint64 lastAddressInUse) const;

/*!
* Mark child and its preceding children conflicting, if overlapping.
*
* @param [in] child The child to check.
*/
void markChildIfConflicting(MemoryVisualizationItem* child);

/*!
* Creates a new child for representing a free memory slot.
*
Expand Down
14 changes: 7 additions & 7 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.12.1139.0
#define VERSION_FULL 3.12.1142.0

#define VERSION_BASEYEAR 0
#define VERSION_DATE "2023-12-07"
#define VERSION_TIME "08:13:53"
#define VERSION_TIME "13:01:29"

#define VERSION_MAJOR 3
#define VERSION_MINOR 12
#define VERSION_BUILDNO 1139
#define VERSION_BUILDNO 1142
#define VERSION_EXTEND 0

#define VERSION_FILE 3,12,1139,0
#define VERSION_PRODUCT 3,12,1139,0
#define VERSION_FILESTR "3,12,1139,0"
#define VERSION_PRODUCTSTR "3,12,1139,0"
#define VERSION_FILE 3,12,1142,0
#define VERSION_PRODUCT 3,12,1142,0
#define VERSION_FILESTR "3,12,1142,0"
#define VERSION_PRODUCTSTR "3,12,1142,0"

#endif

0 comments on commit cf9c726

Please sign in to comment.