Merge pull request #723 from YosysHQ/gatecat/fix-722
gui: Don't destroy context when loading JSON
This commit is contained in:
commit
5e18bb1735
@ -473,19 +473,24 @@ int CommandHandler::exec()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<Context> CommandHandler::load_json(std::string filename)
|
void CommandHandler::load_json(Context *ctx, std::string filename)
|
||||||
{
|
{
|
||||||
dict<std::string, Property> values;
|
ctx->cells.clear();
|
||||||
std::unique_ptr<Context> ctx = createContext(values);
|
ctx->nets.clear();
|
||||||
setupContext(ctx.get());
|
ctx->net_aliases.clear();
|
||||||
setupArchContext(ctx.get());
|
ctx->ports.clear();
|
||||||
|
ctx->hierarchy.clear();
|
||||||
|
ctx->settings.erase(ctx->id("pack"));
|
||||||
|
ctx->settings.erase(ctx->id("place"));
|
||||||
|
ctx->settings.erase(ctx->id("route"));
|
||||||
|
|
||||||
|
setupContext(ctx);
|
||||||
|
setupArchContext(ctx);
|
||||||
{
|
{
|
||||||
std::ifstream f(filename);
|
std::ifstream f(filename);
|
||||||
if (!parse_json(f, filename, ctx.get()))
|
if (!parse_json(f, filename, ctx))
|
||||||
log_error("Loading design failed.\n");
|
log_error("Loading design failed.\n");
|
||||||
}
|
}
|
||||||
customAfterLoad(ctx.get());
|
|
||||||
return ctx;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommandHandler::clear() { vm.clear(); }
|
void CommandHandler::clear() { vm.clear(); }
|
||||||
|
@ -37,7 +37,7 @@ class CommandHandler
|
|||||||
virtual ~CommandHandler(){};
|
virtual ~CommandHandler(){};
|
||||||
|
|
||||||
int exec();
|
int exec();
|
||||||
std::unique_ptr<Context> load_json(std::string filename);
|
void load_json(Context *ctx, std::string filename);
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include "designwidget.h"
|
#include "designwidget.h"
|
||||||
#include "fpgaviewwidget.h"
|
#include "fpgaviewwidget.h"
|
||||||
|
#include "json_frontend.h"
|
||||||
#include "jsonwrite.h"
|
#include "jsonwrite.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
@ -364,8 +365,7 @@ void BaseMainWindow::open_json()
|
|||||||
QString fileName = QFileDialog::getOpenFileName(this, QString("Open JSON"), QString(), QString("*.json"));
|
QString fileName = QFileDialog::getOpenFileName(this, QString("Open JSON"), QString(), QString("*.json"));
|
||||||
if (!fileName.isEmpty()) {
|
if (!fileName.isEmpty()) {
|
||||||
disableActions();
|
disableActions();
|
||||||
ctx = handler->load_json(fileName.toStdString());
|
handler->load_json(ctx.get(), fileName.toStdString());
|
||||||
Q_EMIT contextChanged(ctx.get());
|
|
||||||
Q_EMIT updateTreeView();
|
Q_EMIT updateTreeView();
|
||||||
log("Loading design successful.\n");
|
log("Loading design successful.\n");
|
||||||
updateActions();
|
updateActions();
|
||||||
|
Loading…
Reference in New Issue
Block a user