mirror of https://github.com/mgba-emu/mgba.git
Scripting: Pass back old buffers when reopening view
This commit is contained in:
parent
997adecddc
commit
edc2e1b7f5
|
@ -87,6 +87,10 @@ void ScriptingController::clearController() {
|
||||||
|
|
||||||
void ScriptingController::reset() {
|
void ScriptingController::reset() {
|
||||||
CoreController::Interrupter interrupter(m_controller);
|
CoreController::Interrupter interrupter(m_controller);
|
||||||
|
for (ScriptingTextBuffer* buffer : m_buffers) {
|
||||||
|
delete buffer;
|
||||||
|
}
|
||||||
|
m_buffers.clear();
|
||||||
mScriptContextDetachCore(&m_scriptContext);
|
mScriptContextDetachCore(&m_scriptContext);
|
||||||
mScriptContextDeinit(&m_scriptContext);
|
mScriptContextDeinit(&m_scriptContext);
|
||||||
m_engines.clear();
|
m_engines.clear();
|
||||||
|
@ -105,6 +109,7 @@ void ScriptingController::runCode(const QString& code) {
|
||||||
mScriptTextBuffer* ScriptingController::createTextBuffer(void* context) {
|
mScriptTextBuffer* ScriptingController::createTextBuffer(void* context) {
|
||||||
ScriptingController* self = static_cast<ScriptingController*>(context);
|
ScriptingController* self = static_cast<ScriptingController*>(context);
|
||||||
ScriptingTextBuffer* buffer = new ScriptingTextBuffer(self);
|
ScriptingTextBuffer* buffer = new ScriptingTextBuffer(self);
|
||||||
|
self->m_buffers.append(buffer);
|
||||||
emit self->textBufferCreated(buffer);
|
emit self->textBufferCreated(buffer);
|
||||||
return buffer->textBuffer();
|
return buffer->textBuffer();
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ public:
|
||||||
bool load(VFileDevice& vf, const QString& name);
|
bool load(VFileDevice& vf, const QString& name);
|
||||||
|
|
||||||
mScriptContext* context() { return &m_scriptContext; }
|
mScriptContext* context() { return &m_scriptContext; }
|
||||||
|
QList<ScriptingTextBuffer*> textBuffers() { return m_buffers; }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void log(const QString&);
|
void log(const QString&);
|
||||||
|
@ -58,6 +59,7 @@ private:
|
||||||
|
|
||||||
mScriptEngineContext* m_activeEngine = nullptr;
|
mScriptEngineContext* m_activeEngine = nullptr;
|
||||||
QHash<QString, mScriptEngineContext*> m_engines;
|
QHash<QString, mScriptEngineContext*> m_engines;
|
||||||
|
QList<ScriptingTextBuffer*> m_buffers;
|
||||||
|
|
||||||
std::shared_ptr<CoreController> m_controller;
|
std::shared_ptr<CoreController> m_controller;
|
||||||
};
|
};
|
||||||
|
|
|
@ -35,6 +35,10 @@ ScriptingView::ScriptingView(ScriptingController* controller, ConfigController*
|
||||||
|
|
||||||
m_mruFiles = m_config->getMRU(ConfigController::MRU::Script);
|
m_mruFiles = m_config->getMRU(ConfigController::MRU::Script);
|
||||||
updateMRU();
|
updateMRU();
|
||||||
|
|
||||||
|
for (ScriptingTextBuffer* buffer : controller->textBuffers()) {
|
||||||
|
addTextBuffer(buffer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptingView::submitRepl() {
|
void ScriptingView::submitRepl() {
|
||||||
|
|
Loading…
Reference in New Issue