Skip to content

Commit

Permalink
Merge branch 'develop' into support-device-data-env-var
Browse files Browse the repository at this point in the history
  • Loading branch information
coolbreeze413 committed Oct 16, 2024
2 parents e67c1bc + 625da6b commit 5622a71
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/MainWindow/main_window.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class MainWindow : public QMainWindow, public TopLevelInterface {
void newProjectDlg();
void openProjectDialog(const QString& dir = QString{});
void openExampleProject();
bool closeProject(bool force = false);
bool closeProject(bool force = false, bool skipWelcomePage = false);
void openFileSlot();
void openFilePath(const QString& filePath);
void newDesignCreated(const QString& design);
Expand Down
33 changes: 20 additions & 13 deletions src/MainWindow/main_window_ql.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,13 +230,16 @@ MainWindow::MainWindow(Session* session)
this, &MainWindow::onDesignFilesChanged);
connect(DesignFileWatcher::Instance(), &DesignFileWatcher::designCreated,
this, &MainWindow::onDesignCreated);

#ifndef UPSTREAM_PINPLANNER
connect(DesignFileWatcher::Instance(), &DesignFileWatcher::designFileContentChanged,
TaskStatusWatcher::Instance(), &TaskStatusWatcher::onDesignFilesChanged);
connect(TaskStatusWatcher::Instance(), &TaskStatusWatcher::synthSucceeded, this, [this](){
if (m_pinAssignmentCreator) {
m_pinAssignmentCreator->forceNextPcfFileCheck();
}
refreshPinPlanner();
});
#endif
}

void MainWindow::Tcl_NewProject(int argc, const char* argv[]) {
Expand Down Expand Up @@ -294,7 +297,7 @@ void MainWindow::newFile() {
}

void MainWindow::newProjectDlg() {
if (!closeProject()) return;
if (!closeProject(/*force*/false, /*skipWelcomePage*/true)) return;
newProjdialog->Reset();
newProjdialog->open();
}
Expand Down Expand Up @@ -349,21 +352,30 @@ void MainWindow::openProjectDialog(const QString& dir) {
if (!fileName.isEmpty()) openProject(fileName, false, false);
}

bool MainWindow::closeProject(bool force) {
bool MainWindow::closeProject(bool force, bool skipWelcomePage) {
if (m_projectManager && m_projectManager->HasDesign()) {
if (!force && !confirmCloseProject()) {
return false;
}

TaskStatusWatcher::Instance()->reset();
GlobalSession->CmdLine()->Clear();
CompilerOpenFPGA_ql* compiler_ql = static_cast<CompilerOpenFPGA_ql*>(m_compiler);
if (compiler_ql) {
compiler_ql->CleanScripts();
}

forceStopCompilation();
Project::Instance()->InitProject();
newProjdialog->Reset();
CloseOpenedTabs();
m_showWelcomePage ? showWelcomePage() : ReShowWindow({});

if (skipWelcomePage) {
ReShowWindow({});
} else {
m_showWelcomePage ? showWelcomePage() : ReShowWindow({});
}

setStatusAndProgressText(QString{});
if (m_taskManager) {
m_taskManager->reset();
Expand Down Expand Up @@ -535,6 +547,10 @@ void MainWindow::openProject(const QString& project, bool delayedOpen,
return;
}

if (!closeProject(/*force*/false, /*skipWelcomePage*/true)) {
return;
}

ReShowWindow(project);
loadFile(project);
emit projectOpened();
Expand All @@ -545,12 +561,6 @@ void MainWindow::openProject(const QString& project, bool delayedOpen,
showMessagesTab();
showReportsTab();

GlobalSession->CmdLine()->Clear();
CompilerOpenFPGA_ql* compiler_ql = static_cast<CompilerOpenFPGA_ql*>(m_compiler);
if (compiler_ql) {
compiler_ql->CleanScripts();
}

if (run) startProject(false);
setStatusAndProgressText(QString{});
}
Expand Down Expand Up @@ -774,9 +784,6 @@ void MainWindow::popRecentSetting() {
void MainWindow::onDesignFilesChanged() {
QString msg = "Design files changed. Recompile might be needed.";
setStatusAndProgressText(msg);
#ifndef UPSTREAM_PINPLANNER
TaskStatusWatcher::Instance()->onDesignFilesChanged();
#endif
}

void MainWindow::onDesignCreated() {
Expand Down
5 changes: 5 additions & 0 deletions src/NewProject/ProjectManager/DesignFileWatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ void DesignFileWatcher::init() {
m_fileWatcher = new QFileSystemWatcher{};
QObject::connect(m_fileWatcher, &QFileSystemWatcher::fileChanged, this,
&DesignFileWatcher::designFilesChanged);

// The signal designFileContentChanged notifies explicitly on design file content changes.
// Note: designFilesChanged cannot be used because it also notifies on the setFiles event.
QObject::connect(m_fileWatcher, &QFileSystemWatcher::fileChanged, this,
&DesignFileWatcher::designFileContentChanged);
}

void DesignFileWatcher::emitDesignCreated() { emit designCreated(); }
Expand Down
1 change: 1 addition & 0 deletions src/NewProject/ProjectManager/DesignFileWatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class DesignFileWatcher : public QObject {

signals:
void designFilesChanged();
void designFileContentChanged();
void designCreated();

private:
Expand Down
8 changes: 2 additions & 6 deletions src/NewProject/ProjectManager/TaskStatusWatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,8 @@ void TaskStatusWatcher::onTaskDone(uint taskId, TaskStatus status)

void TaskStatusWatcher::onDesignFilesChanged()
{
if (!m_isDesignChangedFirstTime) {
m_isSynthResultDirty = true;
emit synthResultDirty();
} else {
m_isDesignChangedFirstTime = false;
}
m_isSynthResultDirty = true;
emit synthResultDirty();
}

} // namespace FOEDAG
2 changes: 1 addition & 1 deletion src/NewProject/ProjectManager/TaskStatusWatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class TaskStatusWatcher : public QObject {
public:
static TaskStatusWatcher *Instance();

void reset() { m_isSynthResultDirty = false; }
bool isSynthResultDirty() const { return m_isSynthResultDirty; }

signals:
Expand All @@ -25,7 +26,6 @@ public slots:

private:
bool m_isSynthResultDirty = false;
bool m_isDesignChangedFirstTime = true; // when initially project is loaded it emit signal about design files change, we want to skip this event
};

} // namespace FOEDAG
7 changes: 7 additions & 0 deletions src/NewProject/ProjectManager/project_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,11 @@ int ProjectManager::setDesignFile(const QString& strFileName, bool isFileCopy,
Project::Instance()->projectName(), m_currentFileSet);
fileInfo.setFile(path, strFileName);
}
QFileInfo localPathFileInfoCandidate;
if (!fileInfo.exists() && fileInfo.isRelative()) {
localPathFileInfoCandidate.setFile(getProjectPath(), strFileName);
}

QString suffix = fileInfo.suffix();
if (fileInfo.isDir()) {
QStringList fileList = getAllChildFiles(strFileName);
Expand All @@ -643,6 +648,8 @@ int ProjectManager::setDesignFile(const QString& strFileName, bool isFileCopy,
}
} else if (fileInfo.exists()) {
ret = AddOrCreateFileToFileSet(strFileName, isFileCopy);
} else if (localPathFileInfoCandidate.exists()) {
ret = AddOrCreateFileToFileSet(localPathFileInfoCandidate.filePath(), isFileCopy);
} else {
if (strFileName.contains("/")) {
if (m_designSuffixes.TestSuffix(suffix)) {
Expand Down

0 comments on commit 5622a71

Please sign in to comment.