Commit 2e887d45 authored by Leander Schulten's avatar Leander Schulten
Browse files

Fix Bug where new compiled modules gets not recognised. => compile to .temp...

Fix Bug where new compiled modules gets not recognised. => compile to .temp file, unload old and rename, remove .temp postfix and load new lib
parent 14ccfe08
......@@ -34,7 +34,7 @@ std::pair<int,QString> Compiler::compileToLibrary(const QFileInfo &file,const QS
QProcess p;
#ifdef Q_OS_MAC
p.setEnvironment(QProcess::systemEnvironment()<<"PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Library/TeX/texbin:/usr/local/MacGPG2/bin:/usr/local/share/dotnet:/opt/X11/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands");
QString cmd = compilerCmd + " "+ compilerLibraryFlags + " " + compilerFlags + " " + file.absoluteFilePath() + " -o " + file.absolutePath()+"/"+newLibraryFile + " -I\"/"+includePath + "\" ";
QString cmd = compilerCmd + " "+ compilerLibraryFlags + " " + compilerFlags + " " + file.absoluteFilePath() + " -o " + file.absolutePath()+"/"+newLibraryFile + ".temp" + " -I\"/"+includePath + "\" ";
p.start("bash", QStringList() << "-c" << cmd);
#elif defined(Q_OS_WIN)
QString tempName=newLibraryFile + ".o";
......@@ -83,8 +83,9 @@ std::pair<int,QString> Compiler::compileToLibrary(const QFileInfo &file,const QS
#ifdef Q_OS_MAC
// we have to unload the existing lib first
if(p.exitCode()==0){
ModuleManager::singletone()->singletone()->unloadLibrary(file.absolutePath() + "/" + newLibraryFile);
ModuleManager::singletone()->singletone()->loadModule(file.absolutePath() + "/" + newLibraryFile);
ModuleManager::singletone()->unloadLibrary(file.absolutePath() + "/" + newLibraryFile);
QFile(file.absolutePath() + "/" + newLibraryFile + ".temp").rename(file.absolutePath() + "/" + newLibraryFile);
ModuleManager::singletone()->loadModule(file.absolutePath() + "/" + newLibraryFile);
}
#endif
}
......
......@@ -174,11 +174,9 @@ typedef Modules::Program* (*CreateProgramm)(unsigned int index);
void ModuleManager::loadAllModulesInDir(QDir dir){
qDebug() << dir;
for(auto s : dir.entryInfoList(QDir::Files)){
#ifdef Q_OS_WIN
if(s.suffix() == "old"){
QFile::remove(s.filePath());
}
#endif
if(QLibrary::isLibrary(s.fileName())){
loadModule(s.absoluteFilePath());
}
......
......@@ -382,7 +382,11 @@ namespace Modules {
auto a = o["model"].toArray();
for(auto val_:a){
QJsonObject ob = val_.toObject();
model.push_back(std::make_shared<ProgramBlock>(ob));
try {
model.push_back(std::make_shared<ProgramBlock>(ob));
} catch (std::runtime_error e) {
qDebug() << "Cant parse ProgramBlock : " << e.what();
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment