Skip to content

Commit 57c20ec

Browse files
committed
faster tempfile handling for interactive scripts
1 parent a743db1 commit 57c20ec

File tree

4 files changed

+13
-10
lines changed

4 files changed

+13
-10
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ Press <kbd>Ctrl</kbd> + <kbd>I</kbd> to open the ``QWebInspector`` and go to the
8585

8686
## History
8787

88-
PEB was started in 2013 by Dimitar D. Mitov as a simple GUI for personal database applications.
88+
PEB was started in 2013 by Dimitar D. Mitov as a simple user interface for personal database applications.
8989

9090
## [Thanks and Credits](CREDITS.md)
9191

doc/INTERACTIVE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ PEB interactive Perl scripts are able to receive user input multiple times after
3030
}
3131
```
3232

33-
* **Temporary File Full Path Message**
34-
Every interactive script using temporary file must send the full path of its temporary file to PEB using the following simple JSON message:
33+
* **Temporary File Full Path Message**
34+
Once started, every interactive Pel script using temporary file must send on STDOUT the full path of its temporary file in the following JSON message:
3535

3636
```javascript
3737
{"tempfile":"/path/to/tempfile"}

resources/app/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@
143143
<a class="btn btn-primary" href="perl_info.script">Perl Basic Information</a>
144144
<a class="btn btn-primary" href="sqlite.script">SQLite Test</a>
145145
<a class="btn btn-primary" href="javascript:clearTestData();">Clear Test Data</a>
146-
<a class="btn btn-primary" href="https://www.google.com/">Google</a>
146+
<a class="btn btn-primary" href="https://duckduckgo.com/html">DuckDuckGo</a>
147147
<a class="btn btn-primary" href="javascript:about();" role="button">About</a>
148148
</div>
149149

src/webkit-page.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -354,19 +354,22 @@ public slots:
354354
void qDisplayScriptOutputSlot(QString id, QString output)
355355
{
356356
if (QPage::mainFrame()->url().scheme() == "file") {
357+
QString outputInsertionJavaScript =
358+
id + ".stdoutFunction('" + output + "'); null";
359+
360+
mainFrame()->evaluateJavaScript(outputInsertionJavaScript);
361+
357362
if (output.contains("tempfile")) {
358363
QJsonDocument tempFileJsonDocument =
359364
QJsonDocument::fromJson(output.toUtf8());
360365
QJsonObject tempFileJsonObject = tempFileJsonDocument.object();
361366
QString tempFileFullPath =
362367
tempFileJsonObject["tempfile"].toString();
363368

364-
temporaryFiles.insert(id, tempFileFullPath);
365-
} else {
366-
QString outputInsertionJavaScript =
367-
id + ".stdoutFunction('" + output + "'); null";
368-
369-
mainFrame()->evaluateJavaScript(outputInsertionJavaScript);
369+
QFileInfo tempFileInfo(tempFileFullPath);
370+
if (tempFileInfo.isFile()) {
371+
temporaryFiles.insert(id, tempFileFullPath);
372+
}
370373
}
371374
}
372375
}

0 commit comments

Comments
 (0)