From 40a31a3d406160a9b8c26b04294341284fd137ec Mon Sep 17 00:00:00 2001 From: Mike Fikes Date: Sat, 18 May 2019 10:11:19 -0400 Subject: [PATCH] Block auto-eval until engine ready (#137) Fixes #136 --- Replete/ReplViewController.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Replete/ReplViewController.swift b/Replete/ReplViewController.swift index 021a062..183944b 100644 --- a/Replete/ReplViewController.swift +++ b/Replete/ReplViewController.swift @@ -146,10 +146,10 @@ class ReplViewController: UIViewController, UITableViewDataSource, UITableViewDe NSLog("Initializing..."); DispatchQueue.global(qos: .background).async { appDelegate.initializeJavaScriptEnvironment() + self.initialized = true; DispatchQueue.main.async { // mark ready NSLog("Ready"); - self.initialized = true; let hasText = self.textView.hasText self.evalButton.isEnabled = hasText if (hasText) { @@ -236,6 +236,9 @@ class ReplViewController: UIViewController, UITableViewDataSource, UITableViewDe if (enterPressed && range.location == currentText!.count) { enterPressed = false + while (!self.initialized) { + Thread.sleep(forTimeInterval: 0.1); + } sendAction() return false; }