Turns out we can't construct a QGraphicsScene on a different thread - causes issues with Qt's internal event posting code.
Instead, we now construct just the ByteItem objects on the worker thread. At some point, I'd like to move the item positioning onto a worker thread, but that's for another day.
This commit is contained in:
@@ -31,7 +31,7 @@ target_sources(
|
|||||||
${CMAKE_CURRENT_SOURCE_DIR}/InsightWorker/Tasks/ReadProgramCounter.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/InsightWorker/Tasks/ReadProgramCounter.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/InsightWorker/Tasks/GetTargetState.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/InsightWorker/Tasks/GetTargetState.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/InsightWorker/Tasks/GetTargetDescriptor.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/InsightWorker/Tasks/GetTargetDescriptor.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/InsightWorker/Tasks/ConstructHexViewerByteItemScene.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/InsightWorker/Tasks/ConstructHexViewerByteItems.cpp
|
||||||
|
|
||||||
# Error dialogue window
|
# Error dialogue window
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/UserInterfaces/InsightWindow/Widgets/ErrorDialogue/ErrorDialogue.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/UserInterfaces/InsightWindow/Widgets/ErrorDialogue/ErrorDialogue.cpp
|
||||||
|
|||||||
@@ -1,32 +0,0 @@
|
|||||||
#include "ConstructHexViewerByteItemScene.hpp"
|
|
||||||
|
|
||||||
namespace Bloom
|
|
||||||
{
|
|
||||||
ConstructHexViewerByteItemScene::ConstructHexViewerByteItemScene(
|
|
||||||
const Targets::TargetMemoryDescriptor& memoryDescriptor,
|
|
||||||
std::vector<FocusedMemoryRegion>& focusedMemoryRegions,
|
|
||||||
std::vector<ExcludedMemoryRegion>& excludedMemoryRegions,
|
|
||||||
Widgets::HexViewerWidgetSettings& settings,
|
|
||||||
Widgets::Label* hoveredAddressLabel
|
|
||||||
)
|
|
||||||
: memoryDescriptor(memoryDescriptor)
|
|
||||||
, focusedMemoryRegions(focusedMemoryRegions)
|
|
||||||
, excludedMemoryRegions(excludedMemoryRegions)
|
|
||||||
, settings(settings)
|
|
||||||
, hoveredAddressLabel(hoveredAddressLabel)
|
|
||||||
{}
|
|
||||||
|
|
||||||
void ConstructHexViewerByteItemScene::run(TargetController::TargetControllerConsole&) {
|
|
||||||
auto* scene = new Widgets::ByteItemGraphicsScene(
|
|
||||||
this->memoryDescriptor,
|
|
||||||
this->focusedMemoryRegions,
|
|
||||||
this->excludedMemoryRegions,
|
|
||||||
this->settings,
|
|
||||||
this->hoveredAddressLabel,
|
|
||||||
nullptr
|
|
||||||
);
|
|
||||||
|
|
||||||
scene->moveToThread(nullptr);
|
|
||||||
emit this->sceneCreated(scene);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
#include "ConstructHexViewerByteItems.hpp"
|
||||||
|
|
||||||
|
namespace Bloom
|
||||||
|
{
|
||||||
|
ConstructHexViewerByteItems::ConstructHexViewerByteItems(
|
||||||
|
const Targets::TargetMemoryDescriptor& memoryDescriptor,
|
||||||
|
std::optional<Targets::TargetStackPointer>& currentStackPointer,
|
||||||
|
Widgets::ByteItem** hoveredByteItem,
|
||||||
|
std::set<Widgets::ByteItem*>& highlightedByteItems,
|
||||||
|
Widgets::HexViewerWidgetSettings& settings
|
||||||
|
)
|
||||||
|
: memoryDescriptor(memoryDescriptor)
|
||||||
|
, currentStackPointer(currentStackPointer)
|
||||||
|
, hoveredByteItem(hoveredByteItem)
|
||||||
|
, highlightedByteItems(highlightedByteItems)
|
||||||
|
, settings(settings)
|
||||||
|
{}
|
||||||
|
|
||||||
|
void ConstructHexViewerByteItems::run(TargetController::TargetControllerConsole&) {
|
||||||
|
const auto memorySize = this->memoryDescriptor.size();
|
||||||
|
const auto startAddress = this->memoryDescriptor.addressRange.startAddress;
|
||||||
|
|
||||||
|
for (Targets::TargetMemorySize i = 0; i < memorySize; i++) {
|
||||||
|
const auto address = startAddress + i;
|
||||||
|
|
||||||
|
this->byteItemsByAddress.emplace(
|
||||||
|
address,
|
||||||
|
new Widgets::ByteItem(
|
||||||
|
i,
|
||||||
|
address,
|
||||||
|
this->currentStackPointer,
|
||||||
|
this->hoveredByteItem,
|
||||||
|
this->highlightedByteItems,
|
||||||
|
settings
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
emit this->byteItems(this->byteItemsByAddress);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <optional>
|
||||||
|
#include <set>
|
||||||
|
|
||||||
#include "InsightWorkerTask.hpp"
|
#include "InsightWorkerTask.hpp"
|
||||||
#include "src/Targets/TargetMemory.hpp"
|
#include "src/Targets/TargetMemory.hpp"
|
||||||
|
|
||||||
@@ -7,21 +10,22 @@
|
|||||||
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/FocusedMemoryRegion.hpp"
|
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/FocusedMemoryRegion.hpp"
|
||||||
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/ExcludedMemoryRegion.hpp"
|
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/ExcludedMemoryRegion.hpp"
|
||||||
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemGraphicsScene.hpp"
|
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemGraphicsScene.hpp"
|
||||||
|
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItem.hpp"
|
||||||
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/Label.hpp"
|
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/Label.hpp"
|
||||||
|
|
||||||
namespace Bloom
|
namespace Bloom
|
||||||
{
|
{
|
||||||
class ConstructHexViewerByteItemScene: public InsightWorkerTask
|
class ConstructHexViewerByteItems: public InsightWorkerTask
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ConstructHexViewerByteItemScene(
|
ConstructHexViewerByteItems(
|
||||||
const Targets::TargetMemoryDescriptor& memoryDescriptor,
|
const Targets::TargetMemoryDescriptor& memoryDescriptor,
|
||||||
std::vector<FocusedMemoryRegion>& focusedMemoryRegions,
|
std::optional<Targets::TargetStackPointer>& currentStackPointer,
|
||||||
std::vector<ExcludedMemoryRegion>& excludedMemoryRegions,
|
Widgets::ByteItem** hoveredByteItem,
|
||||||
Widgets::HexViewerWidgetSettings& settings,
|
std::set<Widgets::ByteItem*>& highlightedByteItems,
|
||||||
Widgets::Label* hoveredAddressLabel
|
Widgets::HexViewerWidgetSettings& settings
|
||||||
);
|
);
|
||||||
|
|
||||||
TaskGroups getTaskGroups() const override {
|
TaskGroups getTaskGroups() const override {
|
||||||
@@ -30,15 +34,18 @@ namespace Bloom
|
|||||||
|
|
||||||
signals:
|
signals:
|
||||||
void sceneCreated(Widgets::ByteItemGraphicsScene* scene);
|
void sceneCreated(Widgets::ByteItemGraphicsScene* scene);
|
||||||
|
void byteItems(std::map<Targets::TargetMemoryAddress, Widgets::ByteItem*>& byteItemsByAddress);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void run(TargetController::TargetControllerConsole& targetControllerConsole) override;
|
void run(TargetController::TargetControllerConsole&) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
std::map<Targets::TargetMemoryAddress, Widgets::ByteItem*> byteItemsByAddress;
|
||||||
|
|
||||||
const Targets::TargetMemoryDescriptor& memoryDescriptor;
|
const Targets::TargetMemoryDescriptor& memoryDescriptor;
|
||||||
std::vector<FocusedMemoryRegion>& focusedMemoryRegions;
|
std::optional<Targets::TargetStackPointer>& currentStackPointer;
|
||||||
std::vector<ExcludedMemoryRegion>& excludedMemoryRegions;
|
Widgets::ByteItem** hoveredByteItem;
|
||||||
|
std::set<Widgets::ByteItem*>& highlightedByteItems;
|
||||||
Widgets::HexViewerWidgetSettings& settings;
|
Widgets::HexViewerWidgetSettings& settings;
|
||||||
Widgets::Label* hoveredAddressLabel;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -9,7 +9,6 @@ namespace Bloom::Widgets
|
|||||||
Targets::TargetMemoryAddress address,
|
Targets::TargetMemoryAddress address,
|
||||||
std::optional<Targets::TargetStackPointer>& currentStackPointer,
|
std::optional<Targets::TargetStackPointer>& currentStackPointer,
|
||||||
ByteItem** hoveredByteItem,
|
ByteItem** hoveredByteItem,
|
||||||
AnnotationItem** hoveredAnnotationItem,
|
|
||||||
std::set<ByteItem*>& highlightedByteItems,
|
std::set<ByteItem*>& highlightedByteItems,
|
||||||
const HexViewerWidgetSettings& settings
|
const HexViewerWidgetSettings& settings
|
||||||
)
|
)
|
||||||
@@ -18,7 +17,6 @@ namespace Bloom::Widgets
|
|||||||
, address(address)
|
, address(address)
|
||||||
, currentStackPointer(currentStackPointer)
|
, currentStackPointer(currentStackPointer)
|
||||||
, hoveredByteItem(hoveredByteItem)
|
, hoveredByteItem(hoveredByteItem)
|
||||||
, hoveredAnnotationItem(hoveredAnnotationItem)
|
|
||||||
, highlightedByteItems(highlightedByteItems)
|
, highlightedByteItems(highlightedByteItems)
|
||||||
, settings(settings)
|
, settings(settings)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -45,7 +45,6 @@ namespace Bloom::Widgets
|
|||||||
Targets::TargetMemoryAddress address,
|
Targets::TargetMemoryAddress address,
|
||||||
std::optional<Targets::TargetStackPointer>& currentStackPointer,
|
std::optional<Targets::TargetStackPointer>& currentStackPointer,
|
||||||
ByteItem** hoveredByteItem,
|
ByteItem** hoveredByteItem,
|
||||||
AnnotationItem** hoveredAnnotationItem,
|
|
||||||
std::set<ByteItem*>& highlightedByteItems,
|
std::set<ByteItem*>& highlightedByteItems,
|
||||||
const HexViewerWidgetSettings& settings
|
const HexViewerWidgetSettings& settings
|
||||||
);
|
);
|
||||||
@@ -72,7 +71,6 @@ namespace Bloom::Widgets
|
|||||||
std::optional<QString> asciiValue;
|
std::optional<QString> asciiValue;
|
||||||
|
|
||||||
ByteItem** hoveredByteItem;
|
ByteItem** hoveredByteItem;
|
||||||
AnnotationItem** hoveredAnnotationItem;
|
|
||||||
std::optional<Targets::TargetStackPointer>& currentStackPointer;
|
std::optional<Targets::TargetStackPointer>& currentStackPointer;
|
||||||
std::set<ByteItem*>& highlightedByteItems;
|
std::set<ByteItem*>& highlightedByteItems;
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,20 @@
|
|||||||
#include "ByteItemContainerGraphicsView.hpp"
|
#include "ByteItemContainerGraphicsView.hpp"
|
||||||
|
|
||||||
#include "src/Insight/InsightWorker/InsightWorker.hpp"
|
#include "src/Insight/InsightWorker/InsightWorker.hpp"
|
||||||
#include "src/Insight/InsightWorker/Tasks/ConstructHexViewerByteItemScene.hpp"
|
#include "src/Insight/InsightWorker/Tasks/ConstructHexViewerByteItems.hpp"
|
||||||
|
|
||||||
namespace Bloom::Widgets
|
namespace Bloom::Widgets
|
||||||
{
|
{
|
||||||
using Bloom::Targets::TargetMemoryDescriptor;
|
using Bloom::Targets::TargetMemoryDescriptor;
|
||||||
|
|
||||||
ByteItemContainerGraphicsView::ByteItemContainerGraphicsView(QWidget* parent)
|
ByteItemContainerGraphicsView::ByteItemContainerGraphicsView(
|
||||||
|
const TargetMemoryDescriptor& targetMemoryDescriptor,
|
||||||
|
std::vector<FocusedMemoryRegion>& focusedMemoryRegions,
|
||||||
|
std::vector<ExcludedMemoryRegion>& excludedMemoryRegions,
|
||||||
|
HexViewerWidgetSettings& settings,
|
||||||
|
Label* hoveredAddressLabel,
|
||||||
|
QWidget* parent
|
||||||
|
)
|
||||||
: QGraphicsView(parent)
|
: QGraphicsView(parent)
|
||||||
{
|
{
|
||||||
this->setObjectName("graphics-view");
|
this->setObjectName("graphics-view");
|
||||||
@@ -19,41 +26,31 @@ namespace Bloom::Widgets
|
|||||||
this->setOptimizationFlag(QGraphicsView::DontSavePainterState, true);
|
this->setOptimizationFlag(QGraphicsView::DontSavePainterState, true);
|
||||||
this->setOptimizationFlag(QGraphicsView::DontAdjustForAntialiasing, true);
|
this->setOptimizationFlag(QGraphicsView::DontAdjustForAntialiasing, true);
|
||||||
this->setCacheMode(QGraphicsView::CacheBackground);
|
this->setCacheMode(QGraphicsView::CacheBackground);
|
||||||
}
|
|
||||||
|
|
||||||
void ByteItemContainerGraphicsView::initScene(
|
this->scene = new ByteItemGraphicsScene(
|
||||||
const TargetMemoryDescriptor& targetMemoryDescriptor,
|
|
||||||
std::vector<FocusedMemoryRegion>& focusedMemoryRegions,
|
|
||||||
std::vector<ExcludedMemoryRegion>& excludedMemoryRegions,
|
|
||||||
HexViewerWidgetSettings& settings,
|
|
||||||
Label* hoveredAddressLabel
|
|
||||||
) {
|
|
||||||
auto* constructSceneTask = new ConstructHexViewerByteItemScene(
|
|
||||||
targetMemoryDescriptor,
|
targetMemoryDescriptor,
|
||||||
focusedMemoryRegions,
|
focusedMemoryRegions,
|
||||||
excludedMemoryRegions,
|
excludedMemoryRegions,
|
||||||
settings,
|
settings,
|
||||||
hoveredAddressLabel
|
hoveredAddressLabel,
|
||||||
|
this
|
||||||
);
|
);
|
||||||
|
|
||||||
QObject::connect(
|
|
||||||
constructSceneTask,
|
|
||||||
&ConstructHexViewerByteItemScene::sceneCreated,
|
|
||||||
this,
|
|
||||||
[this] (ByteItemGraphicsScene* scene) {
|
|
||||||
scene->moveToThread(this->thread());
|
|
||||||
scene->setParent(this);
|
|
||||||
|
|
||||||
this->scene = scene;
|
|
||||||
this->scene->refreshRegions();
|
|
||||||
this->scene->setEnabled(this->isEnabled());
|
|
||||||
this->setScene(this->scene);
|
this->setScene(this->scene);
|
||||||
|
}
|
||||||
|
|
||||||
emit this->ready();
|
void ByteItemContainerGraphicsView::initScene() {
|
||||||
|
QObject::connect(
|
||||||
|
this->scene,
|
||||||
|
&ByteItemGraphicsScene::ready,
|
||||||
|
this,
|
||||||
|
[this] {
|
||||||
|
this->scene->setEnabled(this->isEnabled());
|
||||||
|
emit this->sceneReady();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
InsightWorker::queueTask(constructSceneTask);
|
this->scene->init();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ByteItemContainerGraphicsView::scrollToByteItemAtAddress(Targets::TargetMemoryAddress address) {
|
void ByteItemContainerGraphicsView::scrollToByteItemAtAddress(Targets::TargetMemoryAddress address) {
|
||||||
|
|||||||
@@ -18,16 +18,17 @@ namespace Bloom::Widgets
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ByteItemContainerGraphicsView(QWidget* parent);
|
ByteItemContainerGraphicsView(
|
||||||
|
|
||||||
void initScene(
|
|
||||||
const Targets::TargetMemoryDescriptor& targetMemoryDescriptor,
|
const Targets::TargetMemoryDescriptor& targetMemoryDescriptor,
|
||||||
std::vector<FocusedMemoryRegion>& focusedMemoryRegions,
|
std::vector<FocusedMemoryRegion>& focusedMemoryRegions,
|
||||||
std::vector<ExcludedMemoryRegion>& excludedMemoryRegions,
|
std::vector<ExcludedMemoryRegion>& excludedMemoryRegions,
|
||||||
HexViewerWidgetSettings& settings,
|
HexViewerWidgetSettings& settings,
|
||||||
Label* hoveredAddressLabel
|
Label* hoveredAddressLabel,
|
||||||
|
QWidget* parent
|
||||||
);
|
);
|
||||||
|
|
||||||
|
void initScene();
|
||||||
|
|
||||||
[[nodiscard]] ByteItemGraphicsScene* getScene() const {
|
[[nodiscard]] ByteItemGraphicsScene* getScene() const {
|
||||||
return this->scene;
|
return this->scene;
|
||||||
}
|
}
|
||||||
@@ -35,7 +36,7 @@ namespace Bloom::Widgets
|
|||||||
void scrollToByteItemAtAddress(Targets::TargetMemoryAddress address);
|
void scrollToByteItemAtAddress(Targets::TargetMemoryAddress address);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void ready();
|
void sceneReady();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool event(QEvent* event) override;
|
bool event(QEvent* event) override;
|
||||||
|
|||||||
@@ -3,8 +3,11 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
|
||||||
|
#include "src/Insight/InsightWorker/InsightWorker.hpp"
|
||||||
#include "src/Insight/InsightSignals.hpp"
|
#include "src/Insight/InsightSignals.hpp"
|
||||||
|
|
||||||
|
#include "src/Insight/InsightWorker/Tasks/ConstructHexViewerByteItems.hpp"
|
||||||
|
|
||||||
namespace Bloom::Widgets
|
namespace Bloom::Widgets
|
||||||
{
|
{
|
||||||
using Bloom::Targets::TargetMemoryDescriptor;
|
using Bloom::Targets::TargetMemoryDescriptor;
|
||||||
@@ -17,42 +20,19 @@ namespace Bloom::Widgets
|
|||||||
Label* hoveredAddressLabel,
|
Label* hoveredAddressLabel,
|
||||||
QGraphicsView* parent
|
QGraphicsView* parent
|
||||||
)
|
)
|
||||||
: QGraphicsScene(parent)
|
: targetMemoryDescriptor(targetMemoryDescriptor)
|
||||||
, targetMemoryDescriptor(targetMemoryDescriptor)
|
|
||||||
, focusedMemoryRegions(focusedMemoryRegions)
|
, focusedMemoryRegions(focusedMemoryRegions)
|
||||||
, excludedMemoryRegions(excludedMemoryRegions)
|
, excludedMemoryRegions(excludedMemoryRegions)
|
||||||
, settings(settings)
|
, settings(settings)
|
||||||
, hoveredAddressLabel(hoveredAddressLabel)
|
, hoveredAddressLabel(hoveredAddressLabel)
|
||||||
|
, parent(parent)
|
||||||
|
, QGraphicsScene(parent)
|
||||||
{
|
{
|
||||||
this->setObjectName("byte-widget-container");
|
this->setObjectName("byte-widget-container");
|
||||||
|
|
||||||
this->byteAddressContainer = new ByteAddressContainer(this->settings);
|
this->byteAddressContainer = new ByteAddressContainer(this->settings);
|
||||||
this->addItem(this->byteAddressContainer);
|
this->addItem(this->byteAddressContainer);
|
||||||
|
|
||||||
// Construct ByteWidget objects
|
|
||||||
const auto memorySize = this->targetMemoryDescriptor.size();
|
|
||||||
const auto startAddress = this->targetMemoryDescriptor.addressRange.startAddress;
|
|
||||||
for (Targets::TargetMemorySize i = 0; i < memorySize; i++) {
|
|
||||||
const auto address = startAddress + i;
|
|
||||||
|
|
||||||
auto* byteWidget = new ByteItem(
|
|
||||||
i,
|
|
||||||
address,
|
|
||||||
this->currentStackPointer,
|
|
||||||
&(this->hoveredByteWidget),
|
|
||||||
&(this->hoveredAnnotationItem),
|
|
||||||
this->highlightedByteItems,
|
|
||||||
settings
|
|
||||||
);
|
|
||||||
|
|
||||||
this->byteItemsByAddress.emplace(std::pair(
|
|
||||||
address,
|
|
||||||
byteWidget
|
|
||||||
));
|
|
||||||
|
|
||||||
this->addItem(byteWidget);
|
|
||||||
}
|
|
||||||
|
|
||||||
this->displayRelativeAddressAction->setCheckable(true);
|
this->displayRelativeAddressAction->setCheckable(true);
|
||||||
this->displayAbsoluteAddressAction->setCheckable(true);
|
this->displayAbsoluteAddressAction->setCheckable(true);
|
||||||
|
|
||||||
@@ -82,6 +62,35 @@ namespace Bloom::Widgets
|
|||||||
this->setAddressType(AddressType::ABSOLUTE);
|
this->setAddressType(AddressType::ABSOLUTE);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
this->setSceneRect(0, 0, this->getSceneWidth(), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ByteItemGraphicsScene::init() {
|
||||||
|
auto* constructByteItemsTask = new ConstructHexViewerByteItems(
|
||||||
|
this->targetMemoryDescriptor,
|
||||||
|
this->currentStackPointer,
|
||||||
|
&(this->hoveredByteWidget),
|
||||||
|
this->highlightedByteItems,
|
||||||
|
this->settings
|
||||||
|
);
|
||||||
|
|
||||||
|
QObject::connect(
|
||||||
|
constructByteItemsTask,
|
||||||
|
&ConstructHexViewerByteItems::byteItems,
|
||||||
|
this,
|
||||||
|
[this] (std::map<Targets::TargetMemoryAddress, ByteItem*>& byteItemsByAddress) {
|
||||||
|
this->byteItemsByAddress = std::move(byteItemsByAddress);
|
||||||
|
|
||||||
|
for (const auto& [address, byteItem] : this->byteItemsByAddress) {
|
||||||
|
this->addItem(byteItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
this->refreshRegions();
|
||||||
|
emit this->ready();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
InsightWorker::queueTask(constructByteItemsTask);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ByteItemGraphicsScene::updateValues(const Targets::TargetMemoryBuffer& buffer) {
|
void ByteItemGraphicsScene::updateValues(const Targets::TargetMemoryBuffer& buffer) {
|
||||||
@@ -173,7 +182,6 @@ namespace Bloom::Widgets
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ByteItemGraphicsScene::adjustSize(bool forced) {
|
void ByteItemGraphicsScene::adjustSize(bool forced) {
|
||||||
const auto* parent = this->getParent();
|
|
||||||
const auto width = this->getSceneWidth();
|
const auto width = this->getSceneWidth();
|
||||||
|
|
||||||
const auto columnCount = static_cast<std::size_t>(
|
const auto columnCount = static_cast<std::size_t>(
|
||||||
@@ -198,7 +206,7 @@ namespace Bloom::Widgets
|
|||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
width,
|
width,
|
||||||
std::max(static_cast<int>(this->sceneRect().height()), parent->viewport()->height())
|
std::max(static_cast<int>(this->sceneRect().height()), this->parent->viewport()->height())
|
||||||
);
|
);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@@ -220,7 +228,7 @@ namespace Bloom::Widgets
|
|||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
width,
|
width,
|
||||||
std::max(sceneHeight, parent->height())
|
std::max(sceneHeight, this->parent->height())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -414,7 +422,7 @@ namespace Bloom::Widgets
|
|||||||
|
|
||||||
void ByteItemGraphicsScene::contextMenuEvent(QGraphicsSceneContextMenuEvent* event) {
|
void ByteItemGraphicsScene::contextMenuEvent(QGraphicsSceneContextMenuEvent* event) {
|
||||||
if (event->scenePos().x() <= ByteAddressContainer::WIDTH) {
|
if (event->scenePos().x() <= ByteAddressContainer::WIDTH) {
|
||||||
auto* menu = new QMenu(this->getParent());
|
auto* menu = new QMenu(this->parent);
|
||||||
menu->setObjectName("byte-item-address-container-context-menu");
|
menu->setObjectName("byte-item-address-container-context-menu");
|
||||||
|
|
||||||
auto* addressTypeMenu = new QMenu("Address Type", menu);
|
auto* addressTypeMenu = new QMenu("Address Type", menu);
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ namespace Bloom::Widgets
|
|||||||
QGraphicsView* parent
|
QGraphicsView* parent
|
||||||
);
|
);
|
||||||
|
|
||||||
|
void init();
|
||||||
void updateValues(const Targets::TargetMemoryBuffer& buffer);
|
void updateValues(const Targets::TargetMemoryBuffer& buffer);
|
||||||
void updateStackPointer(Targets::TargetStackPointer stackPointer);
|
void updateStackPointer(Targets::TargetStackPointer stackPointer);
|
||||||
void setHighlightedAddresses(const std::set<Targets::TargetMemoryAddress>& highlightedAddresses);
|
void setHighlightedAddresses(const std::set<Targets::TargetMemoryAddress>& highlightedAddresses);
|
||||||
@@ -62,6 +63,7 @@ namespace Bloom::Widgets
|
|||||||
QPointF getByteItemPositionByAddress(Targets::TargetMemoryAddress address);
|
QPointF getByteItemPositionByAddress(Targets::TargetMemoryAddress address);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
void ready();
|
||||||
void byteWidgetsAdjusted();
|
void byteWidgetsAdjusted();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@@ -97,6 +99,7 @@ namespace Bloom::Widgets
|
|||||||
const QMargins margins = QMargins(10, 10, 10, 10);
|
const QMargins margins = QMargins(10, 10, 10, 10);
|
||||||
HexViewerWidgetSettings& settings;
|
HexViewerWidgetSettings& settings;
|
||||||
|
|
||||||
|
QGraphicsView* parent = nullptr;
|
||||||
Label* hoveredAddressLabel = nullptr;
|
Label* hoveredAddressLabel = nullptr;
|
||||||
|
|
||||||
ByteAddressContainer* byteAddressContainer = nullptr;
|
ByteAddressContainer* byteAddressContainer = nullptr;
|
||||||
@@ -112,10 +115,6 @@ namespace Bloom::Widgets
|
|||||||
QAction* displayRelativeAddressAction = new QAction("Relative", this);
|
QAction* displayRelativeAddressAction = new QAction("Relative", this);
|
||||||
QAction* displayAbsoluteAddressAction = new QAction("Absolute", this);
|
QAction* displayAbsoluteAddressAction = new QAction("Absolute", this);
|
||||||
|
|
||||||
QGraphicsView* getParent() const {
|
|
||||||
return dynamic_cast<QGraphicsView*>(this->parent());
|
|
||||||
}
|
|
||||||
|
|
||||||
int getSceneWidth() {
|
int getSceneWidth() {
|
||||||
/*
|
/*
|
||||||
* Minus 2 for the QSS margin on the vertical scrollbar (which isn't accounted for during viewport
|
* Minus 2 for the QSS margin on the vertical scrollbar (which isn't accounted for during viewport
|
||||||
@@ -123,8 +122,7 @@ namespace Bloom::Widgets
|
|||||||
*
|
*
|
||||||
* See https://bugreports.qt.io/browse/QTBUG-99189 for more on this.
|
* See https://bugreports.qt.io/browse/QTBUG-99189 for more on this.
|
||||||
*/
|
*/
|
||||||
auto* parent = this->getParent();
|
return std::max(this->parent->viewport()->width(), 400) - 2;
|
||||||
return std::max(parent != nullptr ? parent->viewport()->width() : 400, 400) - 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateAnnotationValues(const Targets::TargetMemoryBuffer& buffer);
|
void updateAnnotationValues(const Targets::TargetMemoryBuffer& buffer);
|
||||||
|
|||||||
@@ -74,6 +74,15 @@ namespace Bloom::Widgets
|
|||||||
this->loadingHexViewerLabel = this->container->findChild<Label*>("loading-hex-viewer-label");
|
this->loadingHexViewerLabel = this->container->findChild<Label*>("loading-hex-viewer-label");
|
||||||
this->byteItemGraphicsViewContainer = this->container->findChild<QWidget*>("graphics-view-container");
|
this->byteItemGraphicsViewContainer = this->container->findChild<QWidget*>("graphics-view-container");
|
||||||
|
|
||||||
|
this->byteItemGraphicsView = new ByteItemContainerGraphicsView(
|
||||||
|
this->targetMemoryDescriptor,
|
||||||
|
this->focusedMemoryRegions,
|
||||||
|
this->excludedMemoryRegions,
|
||||||
|
this->settings,
|
||||||
|
this->hoveredAddressLabel,
|
||||||
|
this->byteItemGraphicsViewContainer
|
||||||
|
);
|
||||||
|
|
||||||
this->setHoveredRowAndColumnHighlightingEnabled(this->settings.highlightHoveredRowAndCol);
|
this->setHoveredRowAndColumnHighlightingEnabled(this->settings.highlightHoveredRowAndCol);
|
||||||
this->setFocusedMemoryHighlightingEnabled(this->settings.highlightFocusedMemory);
|
this->setFocusedMemoryHighlightingEnabled(this->settings.highlightFocusedMemory);
|
||||||
this->setAnnotationsEnabled(this->settings.displayAnnotations);
|
this->setAnnotationsEnabled(this->settings.displayAnnotations);
|
||||||
@@ -158,11 +167,9 @@ namespace Bloom::Widgets
|
|||||||
}
|
}
|
||||||
|
|
||||||
void HexViewerWidget::init() {
|
void HexViewerWidget::init() {
|
||||||
this->byteItemGraphicsView = new ByteItemContainerGraphicsView(this->byteItemGraphicsViewContainer);
|
|
||||||
|
|
||||||
QObject::connect(
|
QObject::connect(
|
||||||
this->byteItemGraphicsView,
|
this->byteItemGraphicsView,
|
||||||
&ByteItemContainerGraphicsView::ready,
|
&ByteItemContainerGraphicsView::sceneReady,
|
||||||
this,
|
this,
|
||||||
[this] {
|
[this] {
|
||||||
this->byteItemGraphicsScene = this->byteItemGraphicsView->getScene();
|
this->byteItemGraphicsScene = this->byteItemGraphicsView->getScene();
|
||||||
@@ -174,13 +181,7 @@ namespace Bloom::Widgets
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
this->byteItemGraphicsView->initScene(
|
this->byteItemGraphicsView->initScene();
|
||||||
this->targetMemoryDescriptor,
|
|
||||||
this->focusedMemoryRegions,
|
|
||||||
this->excludedMemoryRegions,
|
|
||||||
this->settings,
|
|
||||||
this->hoveredAddressLabel
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void HexViewerWidget::updateValues(const Targets::TargetMemoryBuffer& buffer) {
|
void HexViewerWidget::updateValues(const Targets::TargetMemoryBuffer& buffer) {
|
||||||
|
|||||||
Reference in New Issue
Block a user