mirror of https://github.com/mgba-emu/mgba.git
Qt: Fix crash when calling createBuffer from a callback
This commit is contained in:
parent
e8a39fea95
commit
d21da6df2d
|
@ -18,7 +18,7 @@ class ScriptingTextBuffer : public QObject {
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ScriptingTextBuffer(QObject* parent);
|
||||
ScriptingTextBuffer(QObject* parent = nullptr);
|
||||
|
||||
QTextDocument* document() { return &m_document; };
|
||||
mScriptTextBuffer* textBuffer() { return &m_shim; }
|
||||
|
|
|
@ -35,7 +35,11 @@ void ScriptingTextBufferModel::reset() {
|
|||
mScriptTextBuffer* ScriptingTextBufferModel::createTextBuffer(void* context) {
|
||||
ScriptingTextBufferModel* self = static_cast<ScriptingTextBufferModel*>(context);
|
||||
self->beginInsertRows(QModelIndex(), self->m_buffers.size(), self->m_buffers.size() + 1);
|
||||
ScriptingTextBuffer* buffer = new ScriptingTextBuffer(self);
|
||||
ScriptingTextBuffer* buffer = new ScriptingTextBuffer;
|
||||
if (buffer->thread() != self->thread()) {
|
||||
buffer->moveToThread(self->thread());
|
||||
}
|
||||
buffer->setParent(self);
|
||||
QObject::connect(buffer, &ScriptingTextBuffer::bufferNameChanged, self, &ScriptingTextBufferModel::bufferNameChanged);
|
||||
self->m_buffers.append(buffer);
|
||||
emit self->textBufferCreated(buffer);
|
||||
|
|
Loading…
Reference in New Issue