Browse Source

- coding standards.

- set 'parent' on QObject custom class to ensure object deletion.
cl-refactor
yann300 10 years ago
parent
commit
dbc5201e98
  1. 6
      mix/ApplicationCtx.cpp
  2. 2
      mix/AssemblyDebuggerCtrl.cpp
  3. 1
      mix/AssemblyDebuggerModel.cpp
  4. 1
      mix/AssemblyDebuggerModel.h
  5. 12
      mix/CodeEditorExtensionManager.cpp
  6. 2
      mix/ConstantCompilationModel.h
  7. 6
      mix/DebuggingStateWrapper.cpp
  8. 6
      mix/DebuggingStateWrapper.h
  9. 2
      mix/qml/Debugger.qml

6
mix/ApplicationCtx.cpp

@ -38,10 +38,8 @@ ApplicationCtx* ApplicationCtx::Instance = nullptr;
ApplicationCtx::ApplicationCtx(QQmlApplicationEngine* _engine) ApplicationCtx::ApplicationCtx(QQmlApplicationEngine* _engine)
{ {
m_applicationEngine = _engine; m_applicationEngine = _engine;
m_keyEventManager = std::unique_ptr<KeyEventManager>(); m_keyEventManager = std::unique_ptr<KeyEventManager>(new KeyEventManager());
m_webThree = std::unique_ptr<dev::WebThreeDirect>(); m_webThree = std::unique_ptr<dev::WebThreeDirect>(new WebThreeDirect(std::string("Mix/v") + dev::Version + "/" DEV_QUOTED(ETH_BUILD_TYPE) "/" DEV_QUOTED(ETH_BUILD_PLATFORM), getDataDir() + "/Mix", false, {"eth", "shh"}));
m_webThree.reset(new WebThreeDirect(std::string("Mix/v") + dev::Version + "/" DEV_QUOTED(ETH_BUILD_TYPE) "/" DEV_QUOTED(ETH_BUILD_PLATFORM), getDataDir() + "/Mix", false, {"eth", "shh"}));
m_keyEventManager.reset(new KeyEventManager());
} }
ApplicationCtx::~ApplicationCtx() ApplicationCtx::~ApplicationCtx()

2
mix/AssemblyDebuggerCtrl.cpp

@ -75,7 +75,7 @@ void AssemblyDebuggerCtrl::keyPressed(int _key)
s->setState(debuggingContent.states.at(i)); s->setState(debuggingContent.states.at(i));
wStates.append(s); wStates.append(s);
} }
std::tuple<QList<QObject*>, QQMLMap*> code = DebuggingStateWrapper::getHumanReadableCode(debuggingContent.executionCode); std::tuple<QList<QObject*>, QQMLMap*> code = DebuggingStateWrapper::getHumanReadableCode(debuggingContent.executionCode, this);
ApplicationCtx::getInstance()->appEngine()->rootContext()->setContextProperty("debugStates", QVariant::fromValue(wStates)); ApplicationCtx::getInstance()->appEngine()->rootContext()->setContextProperty("debugStates", QVariant::fromValue(wStates));
ApplicationCtx::getInstance()->appEngine()->rootContext()->setContextProperty("humanReadableExecutionCode", QVariant::fromValue(std::get<0>(code))); ApplicationCtx::getInstance()->appEngine()->rootContext()->setContextProperty("humanReadableExecutionCode", QVariant::fromValue(std::get<0>(code)));
ApplicationCtx::getInstance()->appEngine()->rootContext()->setContextProperty("bytesCodeMapping", QVariant::fromValue(std::get<1>(code))); ApplicationCtx::getInstance()->appEngine()->rootContext()->setContextProperty("bytesCodeMapping", QVariant::fromValue(std::get<1>(code)));

1
mix/AssemblyDebuggerModel.cpp

@ -78,7 +78,6 @@ DebuggingContent AssemblyDebuggerModel::getContractInitiationDebugStates(dev::by
return d; return d;
} }
DebuggingContent AssemblyDebuggerModel::getContractInitiationDebugStates(dev::u256 _value, DebuggingContent AssemblyDebuggerModel::getContractInitiationDebugStates(dev::u256 _value,
dev::u256 _gasPrice, dev::u256 _gasPrice,
dev::u256 _gas, dev::u256 _gas,

1
mix/AssemblyDebuggerModel.h

@ -25,6 +25,7 @@
#include "libethereum/Executive.h" #include "libethereum/Executive.h"
#include "libdevcore/Common.h" #include "libdevcore/Common.h"
#include "DebuggingStateWrapper.h" #include "DebuggingStateWrapper.h"
namespace dev namespace dev
{ {

12
mix/CodeEditorExtensionManager.cpp

@ -64,15 +64,15 @@ void CodeEditorExtensionManager::initExtensions()
initExtension(std::make_shared<AssemblyDebuggerCtrl>(m_doc)); initExtension(std::make_shared<AssemblyDebuggerCtrl>(m_doc));
} }
void CodeEditorExtensionManager::initExtension(std::shared_ptr<Extension> ext) void CodeEditorExtensionManager::initExtension(std::shared_ptr<Extension> _ext)
{ {
if (!ext.get()->contentUrl().isEmpty()) if (!_ext.get()->contentUrl().isEmpty())
{ {
try try
{ {
if (ext.get()->getDisplayBehavior() == ExtensionDisplayBehavior::Tab) if (_ext.get()->getDisplayBehavior() == ExtensionDisplayBehavior::Tab)
{ {
ext.get()->addTabOn(m_tabView); _ext.get()->addTabOn(m_tabView);
} }
} }
catch (...) catch (...)
@ -81,8 +81,8 @@ void CodeEditorExtensionManager::initExtension(std::shared_ptr<Extension> ext)
return; return;
} }
} }
ext.get()->start(); _ext.get()->start();
m_features.append(ext); m_features.append(_ext);
} }
void CodeEditorExtensionManager::setEditor(QQuickItem* _editor) void CodeEditorExtensionManager::setEditor(QQuickItem* _editor)

2
mix/ConstantCompilationModel.h

@ -45,7 +45,7 @@ class ConstantCompilationModel
public: public:
ConstantCompilationModel() {} ConstantCompilationModel() {}
~ConstantCompilationModel() {} ~ConstantCompilationModel() {}
CompilerResult compile(QString code); CompilerResult compile(QString);
}; };
} }

6
mix/DebuggingStateWrapper.cpp

@ -31,7 +31,7 @@ using namespace dev;
using namespace dev::eth; using namespace dev::eth;
using namespace dev::mix; using namespace dev::mix;
std::tuple<QList<QObject*>, QQMLMap*> DebuggingStateWrapper::getHumanReadableCode(const bytes& code) std::tuple<QList<QObject*>, QQMLMap*> DebuggingStateWrapper::getHumanReadableCode(const bytes& code, QObject* _objUsedAsParent)
{ {
QList<QObject*> codeStr; QList<QObject*> codeStr;
QMap<int, int> codeMapping; QMap<int, int> codeMapping;
@ -51,7 +51,7 @@ std::tuple<QList<QObject*>, QQMLMap*> DebuggingStateWrapper::getHumanReadableCod
s = "PUSH 0x" + QString::fromStdString(toHex(bytesConstRef(&code[i + 1], bc))); s = "PUSH 0x" + QString::fromStdString(toHex(bytesConstRef(&code[i + 1], bc)));
i += bc; i += bc;
} }
HumanReadableCode* humanCode = new HumanReadableCode(QString::fromStdString(out.str()) + " " + s, line); HumanReadableCode* humanCode = new HumanReadableCode(QString::fromStdString(out.str()) + " " + s, line, _objUsedAsParent);
codeStr.append(humanCode); codeStr.append(humanCode);
} }
catch (...) catch (...)
@ -61,7 +61,7 @@ std::tuple<QList<QObject*>, QQMLMap*> DebuggingStateWrapper::getHumanReadableCod
break; // probably hit data segment break; // probably hit data segment
} }
} }
return std::make_tuple(codeStr, new QQMLMap(codeMapping)); return std::make_tuple(codeStr, new QQMLMap(codeMapping, _objUsedAsParent));
} }
QString DebuggingStateWrapper::debugStack() QString DebuggingStateWrapper::debugStack()

6
mix/DebuggingStateWrapper.h

@ -65,7 +65,7 @@ class HumanReadableCode: public QObject
Q_PROPERTY(int processIndex READ processIndex) Q_PROPERTY(int processIndex READ processIndex)
public: public:
HumanReadableCode(QString _line, int _processIndex) : m_line(_line), m_processIndex(_processIndex) {} HumanReadableCode(QString _line, int _processIndex, QObject* _parent) : m_line(_line), m_processIndex(_processIndex), QObject(_parent) {}
QString line() { return m_line; } QString line() { return m_line; }
int processIndex() { return m_processIndex; } int processIndex() { return m_processIndex; }
@ -80,7 +80,7 @@ class QQMLMap : public QObject
Q_OBJECT Q_OBJECT
public: public:
QQMLMap(QMap<int, int> _map) : m_map(_map) { } QQMLMap(QMap<int, int> _map, QObject* _parent) : m_map(_map), QObject(_parent) { }
Q_INVOKABLE int getValue(int _key) { return m_map.value(_key); } Q_INVOKABLE int getValue(int _key) { return m_map.value(_key); }
private: private:
@ -118,7 +118,7 @@ public:
QStringList levels(); QStringList levels();
DebuggingState state() { return m_state; } DebuggingState state() { return m_state; }
void setState(DebuggingState _state) { m_state = _state; } void setState(DebuggingState _state) { m_state = _state; }
static std::tuple<QList<QObject*>, QQMLMap*> getHumanReadableCode(bytes const& code); static std::tuple<QList<QObject*>, QQMLMap*> getHumanReadableCode(bytes const& code, QObject* _objUsedAsParent);
private: private:
DebuggingState m_state; DebuggingState m_state;

2
mix/qml/Debugger.qml

@ -84,7 +84,7 @@ Rectangle {
anchors.top: statesList.bottom anchors.top: statesList.bottom
height: parent.height * 0.35 height: parent.height * 0.35
width: parent.width width: parent.width
anchors.topMargin: 13 anchors.topMargin: 15
color: "transparent" color: "transparent"
Label { Label {
id: callStackLabel id: callStackLabel

Loading…
Cancel
Save