| 712 | } |
| 713 | |
| 714 | void DspHost::reloadLiveprog(DspConfig* config) |
| 715 | { |
| 716 | if(config == nullptr) |
| 717 | { |
| 718 | config = _cache; |
| 719 | } |
| 720 | |
| 721 | bool propExists; |
| 722 | bool enableExists; |
| 723 | QString file = chopDoubleQuotes(config->get<QString>(DspConfig::liveprog_file, &propExists)); |
| 724 | bool enabled = config->get<bool>(DspConfig::liveprog_enable, &enableExists); |
| 725 | |
| 726 | if(!enableExists) |
| 727 | { |
| 728 | util::warning("Liveprog enable switch unset. Disabling liveprog."); |
| 729 | enabled = false; |
| 730 | } |
| 731 | |
| 732 | if(!propExists) |
| 733 | { |
| 734 | util::warning("liveprog_file property not found in cache. Disabling liveprog."); |
| 735 | enabled = false; |
| 736 | } |
| 737 | |
| 738 | // Attach log listener |
| 739 | setStdOutHandler(receiveLiveprogStdOut, this); |
| 740 | |
| 741 | QFile f(file); |
| 742 | if(!f.exists()) |
| 743 | { |
| 744 | util::warning("Referenced file does not exist anymore. Disabling liveprog."); |
| 745 | enabled = false; |
| 746 | } |
| 747 | |
| 748 | if (!f.open(QFile::ReadOnly | QFile::Text)) |
| 749 | { |
| 750 | util::error("Cannot open file path. Disabling liveprog."); |
| 751 | enabled = false; |
| 752 | } |
| 753 | QTextStream in(&f); |
| 754 | |
| 755 | |
| 756 | LiveProgDisable(cast(this->_dsp)); |
| 757 | dispatch(EelCompilerStart, f.fileName()); |
| 758 | |
| 759 | QElapsedTimer timer; |
| 760 | timer.start(); |
| 761 | int ret = LiveProgStringParser(cast(this->_dsp), in.readAll().toLocal8Bit().data()); |
| 762 | |
| 763 | // Workaround due to library bug |
| 764 | jdsp_unlock(cast(this->_dsp)); |
| 765 | |
| 766 | float msecs = timer.nsecsElapsed() / 1000000.0; |
| 767 | |
| 768 | const char* errorString = NSEEL_code_getcodeerror(cast(this->_dsp)->eel.vm); |
| 769 | if(errorString != NULL) |
| 770 | { |
| 771 | util::warning("Syntax error in script file, cannot load. Reason: " + std::string(errorString)); |
no test coverage detected