Revert "Job #19766 BUG: Stop or reload all scripts crashes interface fix, part 2."

This reverts commit b4e9840865.
This commit is contained in:
matsukaze 2014-06-10 21:32:23 -04:00
parent b4e9840865
commit a48f38b1d2
4 changed files with 14 additions and 11 deletions

View file

@ -3492,8 +3492,9 @@ ScriptEngine* Application::loadScript(const QString& scriptName, bool loadScript
scriptEngine = new ScriptEngine(NO_SCRIPT, "", &_controllerScriptingInterface); scriptEngine = new ScriptEngine(NO_SCRIPT, "", &_controllerScriptingInterface);
} else { } else {
// start the script on a new thread... // start the script on a new thread...
scriptEngine = new ScriptEngine(scriptName, &_controllerScriptingInterface); QUrl scriptUrl(scriptName);
_scriptEnginesHash.insert(scriptName, scriptEngine); scriptEngine = new ScriptEngine(scriptUrl, &_controllerScriptingInterface);
_scriptEnginesHash.insert(scriptUrl.toString(), scriptEngine);
if (!scriptEngine->hasScript()) { if (!scriptEngine->hasScript()) {
qDebug() << "Application::loadScript(), script failed to load..."; qDebug() << "Application::loadScript(), script failed to load...";

View file

@ -873,7 +873,7 @@ void Particle::endParticleScriptContext(ScriptEngine& engine, ParticleScriptObje
void Particle::executeUpdateScripts() { void Particle::executeUpdateScripts() {
// Only run this particle script if there's a script attached directly to the particle. // Only run this particle script if there's a script attached directly to the particle.
if (!_script.isEmpty()) { if (!_script.isEmpty()) {
ScriptEngine engine(_script, QString("")); ScriptEngine engine(_script);
ParticleScriptObject particleScriptable(this); ParticleScriptObject particleScriptable(this);
startParticleScriptContext(engine, particleScriptable); startParticleScriptContext(engine, particleScriptable);
particleScriptable.emitUpdate(); particleScriptable.emitUpdate();
@ -884,7 +884,7 @@ void Particle::executeUpdateScripts() {
void Particle::collisionWithParticle(Particle* other, const glm::vec3& penetration) { void Particle::collisionWithParticle(Particle* other, const glm::vec3& penetration) {
// Only run this particle script if there's a script attached directly to the particle. // Only run this particle script if there's a script attached directly to the particle.
if (!_script.isEmpty()) { if (!_script.isEmpty()) {
ScriptEngine engine(_script, QString("")); ScriptEngine engine(_script);
ParticleScriptObject particleScriptable(this); ParticleScriptObject particleScriptable(this);
startParticleScriptContext(engine, particleScriptable); startParticleScriptContext(engine, particleScriptable);
ParticleScriptObject otherParticleScriptable(other); 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) { void Particle::collisionWithVoxel(VoxelDetail* voxelDetails, const glm::vec3& penetration) {
// Only run this particle script if there's a script attached directly to the particle. // Only run this particle script if there's a script attached directly to the particle.
if (!_script.isEmpty()) { if (!_script.isEmpty()) {
ScriptEngine engine(_script, QString("")); ScriptEngine engine(_script);
ParticleScriptObject particleScriptable(this); ParticleScriptObject particleScriptable(this);
startParticleScriptContext(engine, particleScriptable); startParticleScriptContext(engine, particleScriptable);
particleScriptable.emitCollisionWithVoxel(*voxelDetails, penetration); particleScriptable.emitCollisionWithVoxel(*voxelDetails, penetration);

View file

@ -93,7 +93,7 @@ ScriptEngine::ScriptEngine(const QString& scriptContents, const QString& fileNam
{ {
} }
ScriptEngine::ScriptEngine(const QString& fileNameString, ScriptEngine::ScriptEngine(const QUrl& scriptURL,
AbstractControllerScriptingInterface* controllerScriptingInterface) : AbstractControllerScriptingInterface* controllerScriptingInterface) :
_scriptContents(), _scriptContents(),
_isFinished(false), _isFinished(false),
@ -110,19 +110,21 @@ ScriptEngine::ScriptEngine(const QString& fileNameString,
_controllerScriptingInterface(controllerScriptingInterface), _controllerScriptingInterface(controllerScriptingInterface),
_avatarData(NULL), _avatarData(NULL),
_scriptName(), _scriptName(),
_fileNameString(fileNameString), _fileNameString(),
_quatLibrary(), _quatLibrary(),
_vec3Library(), _vec3Library(),
_uuidLibrary(), _uuidLibrary(),
_animationCache(this) _animationCache(this)
{ {
QUrl url(fileNameString); QString scriptURLString = scriptURL.toString();
QString scriptUrlString = url.toString(); _fileNameString = scriptURLString;
QUrl url(scriptURL);
// if the scheme length is one or lower, maybe they typed in a file, let's try // if the scheme length is one or lower, maybe they typed in a file, let's try
const int WINDOWS_DRIVE_LETTER_SIZE = 1; const int WINDOWS_DRIVE_LETTER_SIZE = 1;
if (url.scheme().size() <= WINDOWS_DRIVE_LETTER_SIZE) { 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 // ok, let's see if it's valid... and if so, load it

View file

@ -40,7 +40,7 @@ const unsigned int SCRIPT_DATA_CALLBACK_USECS = floor(((1.0 / 60.0f) * 1000 * 10
class ScriptEngine : public QObject { class ScriptEngine : public QObject {
Q_OBJECT Q_OBJECT
public: public:
ScriptEngine(const QString& fileNameString, ScriptEngine(const QUrl& scriptURL,
AbstractControllerScriptingInterface* controllerScriptingInterface = NULL); AbstractControllerScriptingInterface* controllerScriptingInterface = NULL);
ScriptEngine(const QString& scriptContents = NO_SCRIPT, ScriptEngine(const QString& scriptContents = NO_SCRIPT,