Changeset 956
- Timestamp:
- Feb 12, 2014, 11:15:52 PM (11 years ago)
- Location:
- XmlTools2/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
XmlTools2/trunk/xmlpatch.cpp
r955 r956 243 243 QString currXmlFileString; 244 244 245 #ifdef _USE_OLD_JS_ENGINE246 245 QScriptEngine engine; 247 246 QScriptValue engineResult; // variable to check for js_errors 248 #else249 QJSEngine engine;250 QJSValue engineResult; // variable to check for js_errors251 #endif252 247 253 248 // Add echo function so user can debug the code … … 277 272 engineResult=engine.evaluate("main(); function main() {"+jsString+"}"); // main funtion allows to use return to exit prematurely from user code 278 273 279 #ifdef _USE_OLD_JS_ENGINE280 274 if (engine.hasUncaughtException()) { 281 275 displayJsException(engine,engineResult); 282 276 } 283 #else284 checkForJsException(engineResult);285 #endif286 277 287 278 if(!currXmlFile.open(QFile::WriteOnly | QFile::Text | QIODevice::Truncate)){ … … 291 282 engineResult=engine.globalObject().property("$xmlData"); 292 283 293 #ifdef _USE_OLD_JS_ENGINE294 284 if (engine.hasUncaughtException()) { 295 285 displayJsException(engine,engineResult); 296 286 } 297 #else298 checkForJsException(engineResult);299 #endif300 287 301 288 QTextStream(&currXmlFile) << engineResult.toString(); // retreive the modified xml by javascript and save it to the file … … 511 498 } 512 499 513 #ifdef _USE_OLD_JS_ENGINE514 500 void XmlPatch::displayJsException(QScriptEngine &engine, QScriptValue &engineResult){ 515 501 if (engine.hasUncaughtException()) { … … 517 503 } 518 504 } 519 #else520 void XmlPatch::checkForJsException(QJSValue &engineResult){521 if (engineResult.isError()) {522 UtilXmlTools::displayErrorMessage("@CUSTOM_CODE","Uncaught js exception (user code):\n" + engineResult.toString());523 }524 }525 #endif -
XmlTools2/trunk/xmlpatch.h
r953 r956 24 24 void checkPatchVersion(const QString &file, QTextStream &fileStream); 25 25 void checkAndProcessValidCommands(QTextStream &fileStream); 26 #ifdef _USE_OLD_JS_ENGINE27 26 void displayJsException(QScriptEngine &engine, QScriptValue &engineResult); 28 #else29 void checkForJsException(QJSValue &engineResult);30 #endif31 27 }; 32 28 -
XmlTools2/trunk/xmltools.h
r923 r956 2 2 #define XMLTOOLS_H 3 3 4 #define _USE_OLD_JS_ENGINE5 4 6 5 #include <string> 7 6 #include <QtCore> 8 7 #include <stdio.h> 9 #ifdef _USE_OLD_JS_ENGINE // Needs to test each one in terms of performance... At first look seems old engine is faster for the xml parsing method used!10 8 #include <QScriptEngine> 11 #else12 #include <QJSEngine>13 #endif14 9 15 10 #include "utilxmltools.h"
Note:
See TracChangeset
for help on using the changeset viewer.