mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 19:56:44 +02:00
Fixed script editor crash when script calls Script.stop(). Also made the
processEraseMessage wait until it can lock to ensure particles are deleted.
This commit is contained in:
parent
4036f929c9
commit
5013c8c2fa
4 changed files with 22 additions and 10 deletions
|
@ -127,7 +127,8 @@ void ParticleTreeRenderer::renderElement(OctreeElement* element, RenderArgs* arg
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParticleTreeRenderer::processEraseMessage(const QByteArray& dataByteArray, const SharedNodePointer& sourceNode) {
|
void ParticleTreeRenderer::processEraseMessage(const QByteArray& dataByteArray, const SharedNodePointer& sourceNode) {
|
||||||
if (_tree->tryLockForWrite()) {
|
if (_tree){
|
||||||
|
_tree->lockForWrite();
|
||||||
static_cast<ParticleTree*>(_tree)->processEraseMessage(dataByteArray, sourceNode);
|
static_cast<ParticleTree*>(_tree)->processEraseMessage(dataByteArray, sourceNode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,6 +57,11 @@ void ScriptEditorWidget::onScriptModified() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScriptEditorWidget::onScriptEnding() {
|
||||||
|
// signals will automatically be disonnected when the _scriptEngine is deleted later
|
||||||
|
_scriptEngine = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
bool ScriptEditorWidget::isModified() {
|
bool ScriptEditorWidget::isModified() {
|
||||||
return _scriptEditorWidgetUI->scriptEdit->document()->isModified();
|
return _scriptEditorWidgetUI->scriptEdit->document()->isModified();
|
||||||
}
|
}
|
||||||
|
@ -69,11 +74,13 @@ bool ScriptEditorWidget::setRunning(bool run) {
|
||||||
if (run && !save()) {
|
if (run && !save()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clean-up old connections.
|
// Clean-up old connections.
|
||||||
if (_scriptEngine != NULL) {
|
if (_scriptEngine != NULL) {
|
||||||
disconnect(_scriptEngine, &ScriptEngine::runningStateChanged, this, &ScriptEditorWidget::runningStateChanged);
|
disconnect(_scriptEngine, &ScriptEngine::runningStateChanged, this, &ScriptEditorWidget::runningStateChanged);
|
||||||
disconnect(_scriptEngine, &ScriptEngine::errorMessage, this, &ScriptEditorWidget::onScriptError);
|
disconnect(_scriptEngine, &ScriptEngine::errorMessage, this, &ScriptEditorWidget::onScriptError);
|
||||||
disconnect(_scriptEngine, &ScriptEngine::printedMessage, this, &ScriptEditorWidget::onScriptPrint);
|
disconnect(_scriptEngine, &ScriptEngine::printedMessage, this, &ScriptEditorWidget::onScriptPrint);
|
||||||
|
disconnect(_scriptEngine, &ScriptEngine::scriptEnding, this, &ScriptEditorWidget::onScriptEnding);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (run) {
|
if (run) {
|
||||||
|
@ -83,6 +90,7 @@ bool ScriptEditorWidget::setRunning(bool run) {
|
||||||
// Make new connections.
|
// Make new connections.
|
||||||
connect(_scriptEngine, &ScriptEngine::errorMessage, this, &ScriptEditorWidget::onScriptError);
|
connect(_scriptEngine, &ScriptEngine::errorMessage, this, &ScriptEditorWidget::onScriptError);
|
||||||
connect(_scriptEngine, &ScriptEngine::printedMessage, this, &ScriptEditorWidget::onScriptPrint);
|
connect(_scriptEngine, &ScriptEngine::printedMessage, this, &ScriptEditorWidget::onScriptPrint);
|
||||||
|
connect(_scriptEngine, &ScriptEngine::scriptEnding, this, &ScriptEditorWidget::onScriptEnding);
|
||||||
} else {
|
} else {
|
||||||
Application::getInstance()->stopScript(_currentScript);
|
Application::getInstance()->stopScript(_currentScript);
|
||||||
_scriptEngine = NULL;
|
_scriptEngine = NULL;
|
||||||
|
@ -125,6 +133,7 @@ void ScriptEditorWidget::loadFile(const QString& scriptPath) {
|
||||||
disconnect(_scriptEngine, &ScriptEngine::runningStateChanged, this, &ScriptEditorWidget::runningStateChanged);
|
disconnect(_scriptEngine, &ScriptEngine::runningStateChanged, this, &ScriptEditorWidget::runningStateChanged);
|
||||||
disconnect(_scriptEngine, &ScriptEngine::errorMessage, this, &ScriptEditorWidget::onScriptError);
|
disconnect(_scriptEngine, &ScriptEngine::errorMessage, this, &ScriptEditorWidget::onScriptError);
|
||||||
disconnect(_scriptEngine, &ScriptEngine::printedMessage, this, &ScriptEditorWidget::onScriptPrint);
|
disconnect(_scriptEngine, &ScriptEngine::printedMessage, this, &ScriptEditorWidget::onScriptPrint);
|
||||||
|
disconnect(_scriptEngine, &ScriptEngine::scriptEnding, this, &ScriptEditorWidget::onScriptEnding);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
QNetworkAccessManager* networkManager = new QNetworkAccessManager(this);
|
QNetworkAccessManager* networkManager = new QNetworkAccessManager(this);
|
||||||
|
@ -144,6 +153,7 @@ void ScriptEditorWidget::loadFile(const QString& scriptPath) {
|
||||||
connect(_scriptEngine, &ScriptEngine::runningStateChanged, this, &ScriptEditorWidget::runningStateChanged);
|
connect(_scriptEngine, &ScriptEngine::runningStateChanged, this, &ScriptEditorWidget::runningStateChanged);
|
||||||
connect(_scriptEngine, &ScriptEngine::errorMessage, this, &ScriptEditorWidget::onScriptError);
|
connect(_scriptEngine, &ScriptEngine::errorMessage, this, &ScriptEditorWidget::onScriptError);
|
||||||
connect(_scriptEngine, &ScriptEngine::printedMessage, this, &ScriptEditorWidget::onScriptPrint);
|
connect(_scriptEngine, &ScriptEngine::printedMessage, this, &ScriptEditorWidget::onScriptPrint);
|
||||||
|
connect(_scriptEngine, &ScriptEngine::scriptEnding, this, &ScriptEditorWidget::onScriptEnding);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,7 @@ private slots:
|
||||||
void onScriptError(const QString& message);
|
void onScriptError(const QString& message);
|
||||||
void onScriptPrint(const QString& message);
|
void onScriptPrint(const QString& message);
|
||||||
void onScriptModified();
|
void onScriptModified();
|
||||||
|
void onScriptEnding();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::ScriptEditorWidget* _scriptEditorWidgetUI;
|
Ui::ScriptEditorWidget* _scriptEditorWidgetUI;
|
||||||
|
|
|
@ -276,7 +276,7 @@ unsigned char* pointToOctalCode(float x, float y, float z, float s) {
|
||||||
unsigned char* pointToVoxel(float x, float y, float z, float s, unsigned char r, unsigned char g, unsigned char b ) {
|
unsigned char* pointToVoxel(float x, float y, float z, float s, unsigned char r, unsigned char g, unsigned char b ) {
|
||||||
|
|
||||||
// special case for size 1, the root node
|
// special case for size 1, the root node
|
||||||
if (s >= 1.0) {
|
if (s >= 1.0f) {
|
||||||
unsigned char* voxelOut = new unsigned char;
|
unsigned char* voxelOut = new unsigned char;
|
||||||
*voxelOut = 0;
|
*voxelOut = 0;
|
||||||
return voxelOut;
|
return voxelOut;
|
||||||
|
@ -289,7 +289,7 @@ unsigned char* pointToVoxel(float x, float y, float z, float s, unsigned char r,
|
||||||
// voxel of size S.
|
// voxel of size S.
|
||||||
unsigned int voxelSizeInOctets = 1;
|
unsigned int voxelSizeInOctets = 1;
|
||||||
while (sTest > s) {
|
while (sTest > s) {
|
||||||
sTest /= 2.0;
|
sTest /= 2.0f;
|
||||||
voxelSizeInOctets++;
|
voxelSizeInOctets++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -314,11 +314,11 @@ unsigned char* pointToVoxel(float x, float y, float z, float s, unsigned char r,
|
||||||
if (x >= xTest) {
|
if (x >= xTest) {
|
||||||
//<write 1 bit>
|
//<write 1 bit>
|
||||||
byte = (byte << 1) | true;
|
byte = (byte << 1) | true;
|
||||||
xTest += sTest/2.0;
|
xTest += sTest/2.0f;
|
||||||
} else {
|
} else {
|
||||||
//<write 0 bit;>
|
//<write 0 bit;>
|
||||||
byte = (byte << 1) | false;
|
byte = (byte << 1) | false;
|
||||||
xTest -= sTest/2.0;
|
xTest -= sTest/2.0f;
|
||||||
}
|
}
|
||||||
bitInByteNDX++;
|
bitInByteNDX++;
|
||||||
// If we've reached the last bit of the byte, then we want to copy this byte
|
// If we've reached the last bit of the byte, then we want to copy this byte
|
||||||
|
@ -333,11 +333,11 @@ unsigned char* pointToVoxel(float x, float y, float z, float s, unsigned char r,
|
||||||
if (y >= yTest) {
|
if (y >= yTest) {
|
||||||
//<write 1 bit>
|
//<write 1 bit>
|
||||||
byte = (byte << 1) | true;
|
byte = (byte << 1) | true;
|
||||||
yTest += sTest/2.0;
|
yTest += sTest/2.0f;
|
||||||
} else {
|
} else {
|
||||||
//<write 0 bit;>
|
//<write 0 bit;>
|
||||||
byte = (byte << 1) | false;
|
byte = (byte << 1) | false;
|
||||||
yTest -= sTest/2.0;
|
yTest -= sTest/2.0f;
|
||||||
}
|
}
|
||||||
bitInByteNDX++;
|
bitInByteNDX++;
|
||||||
// If we've reached the last bit of the byte, then we want to copy this byte
|
// If we've reached the last bit of the byte, then we want to copy this byte
|
||||||
|
@ -352,11 +352,11 @@ unsigned char* pointToVoxel(float x, float y, float z, float s, unsigned char r,
|
||||||
if (z >= zTest) {
|
if (z >= zTest) {
|
||||||
//<write 1 bit>
|
//<write 1 bit>
|
||||||
byte = (byte << 1) | true;
|
byte = (byte << 1) | true;
|
||||||
zTest += sTest/2.0;
|
zTest += sTest/2.0f;
|
||||||
} else {
|
} else {
|
||||||
//<write 0 bit;>
|
//<write 0 bit;>
|
||||||
byte = (byte << 1) | false;
|
byte = (byte << 1) | false;
|
||||||
zTest -= sTest/2.0;
|
zTest -= sTest/2.0f;
|
||||||
}
|
}
|
||||||
bitInByteNDX++;
|
bitInByteNDX++;
|
||||||
// If we've reached the last bit of the byte, then we want to copy this byte
|
// If we've reached the last bit of the byte, then we want to copy this byte
|
||||||
|
@ -369,7 +369,7 @@ unsigned char* pointToVoxel(float x, float y, float z, float s, unsigned char r,
|
||||||
}
|
}
|
||||||
|
|
||||||
octetsDone++;
|
octetsDone++;
|
||||||
sTest /= 2.0;
|
sTest /= 2.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we've got here, and we didn't fill the last byte, we need to zero pad this
|
// If we've got here, and we didn't fill the last byte, we need to zero pad this
|
||||||
|
|
Loading…
Reference in a new issue