mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 08:04:01 +02:00
Job #19766 BUG: Stop or reload all scripts crashes interface fix, part 2.
Keep the scriptUrl internal to the ScriptEngine class and refer to it externally by the file name string. Change the ScriptEngine constructor to accept a filename QString, instead of a QUrl. Resolve constructor ambiguity in Particle, which creates anonymous ScriptEngine.
This commit is contained in:
parent
c8c8bccbf3
commit
b4e9840865
4 changed files with 11 additions and 14 deletions
|
@ -3492,9 +3492,8 @@ ScriptEngine* Application::loadScript(const QString& scriptName, bool loadScript
|
|||
scriptEngine = new ScriptEngine(NO_SCRIPT, "", &_controllerScriptingInterface);
|
||||
} else {
|
||||
// start the script on a new thread...
|
||||
QUrl scriptUrl(scriptName);
|
||||
scriptEngine = new ScriptEngine(scriptUrl, &_controllerScriptingInterface);
|
||||
_scriptEnginesHash.insert(scriptUrl.toString(), scriptEngine);
|
||||
scriptEngine = new ScriptEngine(scriptName, &_controllerScriptingInterface);
|
||||
_scriptEnginesHash.insert(scriptName, scriptEngine);
|
||||
|
||||
if (!scriptEngine->hasScript()) {
|
||||
qDebug() << "Application::loadScript(), script failed to load...";
|
||||
|
|
|
@ -873,7 +873,7 @@ void Particle::endParticleScriptContext(ScriptEngine& engine, ParticleScriptObje
|
|||
void Particle::executeUpdateScripts() {
|
||||
// Only run this particle script if there's a script attached directly to the particle.
|
||||
if (!_script.isEmpty()) {
|
||||
ScriptEngine engine(_script);
|
||||
ScriptEngine engine(_script, QString(""));
|
||||
ParticleScriptObject particleScriptable(this);
|
||||
startParticleScriptContext(engine, particleScriptable);
|
||||
particleScriptable.emitUpdate();
|
||||
|
@ -884,7 +884,7 @@ void Particle::executeUpdateScripts() {
|
|||
void Particle::collisionWithParticle(Particle* other, const glm::vec3& penetration) {
|
||||
// Only run this particle script if there's a script attached directly to the particle.
|
||||
if (!_script.isEmpty()) {
|
||||
ScriptEngine engine(_script);
|
||||
ScriptEngine engine(_script, QString(""));
|
||||
ParticleScriptObject particleScriptable(this);
|
||||
startParticleScriptContext(engine, particleScriptable);
|
||||
ParticleScriptObject otherParticleScriptable(other);
|
||||
|
@ -896,7 +896,7 @@ void Particle::collisionWithParticle(Particle* other, const glm::vec3& penetrati
|
|||
void Particle::collisionWithVoxel(VoxelDetail* voxelDetails, const glm::vec3& penetration) {
|
||||
// Only run this particle script if there's a script attached directly to the particle.
|
||||
if (!_script.isEmpty()) {
|
||||
ScriptEngine engine(_script);
|
||||
ScriptEngine engine(_script, QString(""));
|
||||
ParticleScriptObject particleScriptable(this);
|
||||
startParticleScriptContext(engine, particleScriptable);
|
||||
particleScriptable.emitCollisionWithVoxel(*voxelDetails, penetration);
|
||||
|
|
|
@ -93,7 +93,7 @@ ScriptEngine::ScriptEngine(const QString& scriptContents, const QString& fileNam
|
|||
{
|
||||
}
|
||||
|
||||
ScriptEngine::ScriptEngine(const QUrl& scriptURL,
|
||||
ScriptEngine::ScriptEngine(const QString& fileNameString,
|
||||
AbstractControllerScriptingInterface* controllerScriptingInterface) :
|
||||
_scriptContents(),
|
||||
_isFinished(false),
|
||||
|
@ -110,21 +110,19 @@ ScriptEngine::ScriptEngine(const QUrl& scriptURL,
|
|||
_controllerScriptingInterface(controllerScriptingInterface),
|
||||
_avatarData(NULL),
|
||||
_scriptName(),
|
||||
_fileNameString(),
|
||||
_fileNameString(fileNameString),
|
||||
_quatLibrary(),
|
||||
_vec3Library(),
|
||||
_uuidLibrary(),
|
||||
_animationCache(this)
|
||||
{
|
||||
QString scriptURLString = scriptURL.toString();
|
||||
_fileNameString = scriptURLString;
|
||||
|
||||
QUrl url(scriptURL);
|
||||
QUrl url(fileNameString);
|
||||
QString scriptUrlString = url.toString();
|
||||
|
||||
// if the scheme length is one or lower, maybe they typed in a file, let's try
|
||||
const int WINDOWS_DRIVE_LETTER_SIZE = 1;
|
||||
if (url.scheme().size() <= WINDOWS_DRIVE_LETTER_SIZE) {
|
||||
url = QUrl::fromLocalFile(scriptURLString);
|
||||
url = QUrl::fromLocalFile(scriptUrlString);
|
||||
}
|
||||
|
||||
// ok, let's see if it's valid... and if so, load it
|
||||
|
|
|
@ -40,7 +40,7 @@ const unsigned int SCRIPT_DATA_CALLBACK_USECS = floor(((1.0 / 60.0f) * 1000 * 10
|
|||
class ScriptEngine : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
ScriptEngine(const QUrl& scriptURL,
|
||||
ScriptEngine(const QString& fileNameString,
|
||||
AbstractControllerScriptingInterface* controllerScriptingInterface = NULL);
|
||||
|
||||
ScriptEngine(const QString& scriptContents = NO_SCRIPT,
|
||||
|
|
Loading…
Reference in a new issue