Skip to content

Commit

Permalink
fix: [debugger] wrong debug state when activating project
Browse files Browse the repository at this point in the history
log:
  • Loading branch information
LiHua000 authored and deepin-mozart committed Jun 5, 2024
1 parent 715e4a4 commit 0953afb
Show file tree
Hide file tree
Showing 15 changed files with 46 additions and 45 deletions.
2 changes: 1 addition & 1 deletion src/common/util/eventdefinitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ OPI_OBJECT(project,
OPI_INTERFACE(openProject, "kitName", "language", "workspace")
OPI_INTERFACE(activeProject, "kitName", "language", "workspace")
// out
OPI_INTERFACE(activedProject, "projectInfo")
OPI_INTERFACE(activatedProject, "projectInfo")
OPI_INTERFACE(deletedProject, "projectInfo")
OPI_INTERFACE(createdProject, "projectInfo")
OPI_INTERFACE(projectUpdated, "projectInfo")
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/builder/mainframe/buildmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -395,13 +395,13 @@ void BuildManager::slotResetBuildUI()
uiController.switchContext(tr("&Build"));
}

void BuildManager::setActivedProjectInfo(const QString &kitName, const QString &workingDir)
void BuildManager::setActivatedProjectInfo(const QString &kitName, const QString &workingDir)
{
d->activedKitName = kitName;
d->activedWorkingDir = workingDir;
}

void BuildManager::clearActivedProjectInfo()
void BuildManager::clearActivatedProjectInfo()
{
d->activedKitName.clear();
d->activedWorkingDir.clear();
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/builder/mainframe/buildmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ class BuildManager : public QObject
ProblemOutputPane *getProblemOutputPane() const;
DTK_WIDGET_NAMESPACE::DWidget *getCompileWidget() const;

void setActivedProjectInfo(const QString &kitName, const QString &workingDir);
void clearActivedProjectInfo();
void setActivatedProjectInfo(const QString &kitName, const QString &workingDir);
void clearActivatedProjectInfo();

bool handleCommand(const QList<BuildCommandInfo> &info, bool isSynchronous);

Expand Down
10 changes: 5 additions & 5 deletions src/plugins/builder/transceiver/builderreceiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@ QStringList BuilderReceiver::topics()

void BuilderReceiver::eventProcess(const dpf::Event &event)
{
if (event.data() == project.activedProject.name) {
QVariant proInfoVar = event.property(project.activedProject.pKeys[0]);
if (event.data() == project.activatedProject.name) {
QVariant proInfoVar = event.property(project.activatedProject.pKeys[0]);
dpfservice::ProjectInfo projectInfo = qvariant_cast<dpfservice::ProjectInfo>(proInfoVar);
BuildManager::instance()->setActivedProjectInfo(projectInfo.kitName(), projectInfo.workspaceFolder());
BuildManager::instance()->setActivatedProjectInfo(projectInfo.kitName(), projectInfo.workspaceFolder());
} else if (event.data() == project.createdProject.name) {
QVariant proInfoVar = event.property(project.createdProject.pKeys[0]);
dpfservice::ProjectInfo projectInfo = qvariant_cast<dpfservice::ProjectInfo>(proInfoVar);
BuildManager::instance()->setActivedProjectInfo(projectInfo.kitName(), projectInfo.workspaceFolder());
BuildManager::instance()->setActivatedProjectInfo(projectInfo.kitName(), projectInfo.workspaceFolder());
} else if (event.data() == project.deletedProject.name) {
QVariant proInfoVar = event.property(project.deletedProject.pKeys[0]);
dpfservice::ProjectInfo projectInfo = qvariant_cast<dpfservice::ProjectInfo>(proInfoVar);
BuildManager::instance()->clearActivedProjectInfo();
BuildManager::instance()->clearActivatedProjectInfo();
} else if (event.data() == symbol.parseDone.name) {
bool bSuccess = event.property("success").toBool();
if(!bSuccess) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ void ProjectCmakeReceiver::eventProcess(const dpf::Event &event)
builderEvent(event);
}

if (event.data() == project.activedProject.name) {
QVariant proInfoVar = event.property(project.activedProject.pKeys[0]);
if (event.data() == project.activatedProject.name) {
QVariant proInfoVar = event.property(project.activatedProject.pKeys[0]);
dpfservice::ProjectInfo projectInfo = qvariant_cast<dpfservice::ProjectInfo>(proInfoVar);
TargetsManager::instance()->readTargets(projectInfo.buildFolder(), projectInfo.workspaceFolder());
}
Expand Down
23 changes: 12 additions & 11 deletions src/plugins/debugger/dap/dapdebugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,12 @@ void DAPDebugger::startDebug()
if (d->currentSession == d->remoteSession)
d->currentSession = d->localSession;

updateRunState(kPreparing);
auto &ctx = dpfInstance.serviceContext();
LanguageService *service = ctx.service<LanguageService>(LanguageService::name());
if (service) {
auto generator = service->create<LanguageGenerator>(d->activeProjectKitName);
if (generator) {
updateRunState(kPreparing);
if (generator->isNeedBuild()) {
d->currentBuildUuid = requestBuild();
} else {
Expand Down Expand Up @@ -705,17 +705,15 @@ void DAPDebugger::handleEvents(const dpf::Event &event)
}
} else if (event.data() == debugger.prepareDebugProgress.name) {
printOutput(event.property(debugger.prepareDebugProgress.pKeys[0]).toString());
} else if (event.data() == project.activedProject.name) {
getActiveProjectInfo() = qvariant_cast<ProjectInfo>(event.property(project.activedProject.pKeys[0]));
d->activeProjectKitName = getActiveProjectInfo().kitName();
updateRunState(kNoRun);
} else if (event.data() == project.createdProject.name) {
getActiveProjectInfo() = qvariant_cast<ProjectInfo>(event.property(project.createdProject.pKeys[0]));
d->activeProjectKitName = getActiveProjectInfo().kitName();
updateRunState(kNoRun);
} else if (event.data() == project.activatedProject.name) {
d->projectInfo = qvariant_cast<ProjectInfo>(event.property("projectInfo"));
d->activeProjectKitName = d->projectInfo.kitName();
} else if (event.data() == project.deletedProject.name) {
d->activeProjectKitName.clear();
updateRunState(kNoRun);
auto prjInfo = event.property("projectInfo").value<dpfservice::ProjectInfo>();
if (d->projectInfo.isSame(prjInfo)) {
d->activeProjectKitName.clear();
updateRunState(kNoRun);
}
} else if (event.data() == editor.switchedFile.name) {
QString filePath = event.property(editor.switchedFile.pKeys[0]).toString();
if (d->currentOpenedFileName != filePath) {
Expand Down Expand Up @@ -1143,6 +1141,9 @@ void DAPDebugger::updateWatchingVariables()

void DAPDebugger::exitDebug()
{
//abort debugger
abortDebug();

// Change UI.
editor.removeDebugLine();
d->variablesPane->hide();
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/debugger/debugmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,8 @@ void DebugManager::handleEvents(const dpf::Event &event)
QString data = event.data().toString();
if (event.data() == debugger.prepareDebugProgress.name) {
// TODO(logan)
} else if (event.data() == project.activedProject.name) {
auto projectInfo = qvariant_cast<ProjectInfo>(event.property(project.activedProject.pKeys[0]));
} else if (event.data() == project.activatedProject.name) {
auto projectInfo = qvariant_cast<ProjectInfo>(event.property(project.activatedProject.pKeys[0]));
activeProjectKitName = projectInfo.kitName();
} else if (event.data() == project.createdProject.name) {
auto projectInfo = qvariant_cast<ProjectInfo>(event.property(project.createdProject.pKeys[0]));
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/debugger/runner/runner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ void Runner::handleEvents(const dpf::Event &event)
if (d->currentOpenedFilePath == filePath) {
d->currentOpenedFilePath.clear();
}
} else if (event.data() == project.activedProject.name) {
} else if (event.data() == project.activatedProject.name) {
QVariant proInfoVar = event.property("projectInfo");
dpfservice::ProjectInfo projectInfo = qvariant_cast<dpfservice::ProjectInfo>(proInfoVar);
auto programs = projectInfo.exePrograms();
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/filebrowser/transceiver/filebrowserreceiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ QStringList FileBrowserReceiver::topics()

void FileBrowserReceiver::eventProcess(const dpf::Event &event)
{
if (event.data() == project.activedProject.name) {
QVariant proInfoVar = event.property(project.activedProject.pKeys[0]);
if (event.data() == project.activatedProject.name) {
QVariant proInfoVar = event.property(project.activatedProject.pKeys[0]);
dpfservice::ProjectInfo proInfo = qvariant_cast<dpfservice::ProjectInfo>(proInfoVar);
TreeViewKeeper::instance()->treeView()->setProjectInfo(proInfo);
} else if (event.data() == project.deletedProject.name) {
TreeViewKeeper::instance()->treeView()->setProjectInfo({});
} else if (event.data() == project.createdProject.name) {
QVariant proInfoVar = event.property(project.activedProject.pKeys[0]);
QVariant proInfoVar = event.property(project.activatedProject.pKeys[0]);
dpfservice::ProjectInfo proInfo = qvariant_cast<dpfservice::ProjectInfo>(proInfoVar);
TreeViewKeeper::instance()->treeView()->setProjectInfo(proInfo);
}
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/git/transceiver/gitreceiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ GitReceiver::GitReceiver(QObject *parent)
using namespace std::placeholders;
eventHandleMap.insert(editor.switchedFile.name, std::bind(&GitReceiver::handleSwitchedFileEvent, this, _1));
eventHandleMap.insert(editor.contextMenu.name, std::bind(&GitReceiver::handleContextMenuEvent, this, _1));
eventHandleMap.insert(project.activedProject.name, std::bind(&GitReceiver::handleProjectChangedEvent, this, _1));
eventHandleMap.insert(project.activatedProject.name, std::bind(&GitReceiver::handleProjectChangedEvent, this, _1));
eventHandleMap.insert(project.deletedProject.name, std::bind(&GitReceiver::handleProjectChangedEvent, this, _1));
}

Expand Down
8 changes: 4 additions & 4 deletions src/plugins/project/transceiver/projectcorereceiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ void ProjectCoreReceiver::eventProcess(const dpf::Event &event)
using namespace dpfservice;
if (event.data() == project.activeProject.name) {
auto infos = ProjectKeeper::instance()->treeView()->getAllProjectInfo();
QString kitName = event.property(project.openProject.pKeys[0]).toString();
QString language = event.property(project.openProject.pKeys[1]).toString();
QString workspace = event.property(project.openProject.pKeys[2]).toString();
QString kitName = event.property("kitName").toString();
QString language = event.property("language").toString();
QString workspace = event.property("workspace").toString();
ProjectKeeper::instance()->treeView()->activeProjectInfo(kitName, language, workspace);
} else if (event.data() == project.openProject.name) {
uiController.doSwitch(dpfservice::MWNA_EDIT);
Expand All @@ -60,7 +60,7 @@ void ProjectCoreReceiver::eventProcess(const dpf::Event &event)
ProjectKeeper::instance()->treeView()->expandAll();
} else if (event.data() == workspace.foldAll.name) {
ProjectKeeper::instance()->treeView()->collapseAll();
} else if (event.data() == project.activedProject.name) {
} else if (event.data() == project.activatedProject.name) {
QVariant proInfoVar = event.property("projectInfo");
dpfservice::ProjectInfo projectInfo = qvariant_cast<dpfservice::ProjectInfo>(proInfoVar);

Expand Down
2 changes: 1 addition & 1 deletion src/plugins/project/transceiver/sendevents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

void SendEvents::projectActived(const dpfservice::ProjectInfo &info)
{
project.activedProject(info);
project.activatedProject(info);
}

void SendEvents::projectCreated(const dpfservice::ProjectInfo &info)
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/symbol/transceiver/symbolreceiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ QStringList SymbolReceiver::topics()

void SymbolReceiver::eventProcess(const dpf::Event &event)
{
if (event.data() == project.activedProject.name) {
QString projectInfoKey = project.activedProject.pKeys[0];
if (event.data() == project.activatedProject.name) {
QString projectInfoKey = project.activatedProject.pKeys[0];
dpfservice::ProjectInfo info = qvariant_cast<dpfservice::ProjectInfo>
(event.property(projectInfoKey));
QString workspace = info.workspaceFolder();
Expand Down
12 changes: 6 additions & 6 deletions src/plugins/valgrind/mainframe/valgrindrunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class ValgrindRunnerPrivate

QStringList ValgrindArgs;
dpfservice::ProjectInfo projectInfo;
QString activedProjectKitName;
QString activatedProjectKitName;
QString workingDir;
QString currentFilePath;
QString targetPath;
Expand Down Expand Up @@ -73,7 +73,7 @@ void ValgrindRunner::initialize()
});
});

setActionsStatus(d->activedProjectKitName);
setActionsStatus(d->activatedProjectKitName);
}

void ValgrindRunner::runValgrind(const QString &type)
Expand Down Expand Up @@ -157,13 +157,13 @@ void ValgrindRunner::setActionsStatus(const QString &kitName)
void ValgrindRunner::saveCurrentProjectInfo(const ProjectInfo &projectInfo)
{
d->projectInfo = projectInfo;
d->activedProjectKitName = d->projectInfo.kitName();
setActionsStatus(d->activedProjectKitName);
d->activatedProjectKitName = d->projectInfo.kitName();
setActionsStatus(d->activatedProjectKitName);
}

void ValgrindRunner::removeProjectInfo()
{
d->activedProjectKitName.clear();
d->activatedProjectKitName.clear();
setActionsStatus("");
}

Expand All @@ -182,7 +182,7 @@ void ValgrindRunner::runBuilding()
auto &ctx = dpfInstance.serviceContext();
LanguageService *service = ctx.service<LanguageService>(LanguageService::name());
if (service) {
auto generator = service->create<LanguageGenerator>(d->activedProjectKitName);
auto generator = service->create<LanguageGenerator>(d->activatedProjectKitName);
if (generator) {
if (generator->isNeedBuild()) {
generator->build(d->projectInfo.workspaceFolder());
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/valgrind/transceiver/valgrindreceiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ QStringList ValgrindReceiver::topics()

void ValgrindReceiver::eventProcess(const dpf::Event &event)
{
if (event.data() == project.activedProject.name) {
QVariant proInfoVar = event.property(project.activedProject.pKeys[0]);
if (event.data() == project.activatedProject.name) {
QVariant proInfoVar = event.property(project.activatedProject.pKeys[0]);
dpfservice::ProjectInfo projectInfo = qvariant_cast<dpfservice::ProjectInfo>(proInfoVar);
QString buildFolder = projectInfo.buildFolder();
ValgrindRunner::instance()->saveCurrentProjectInfo(projectInfo);
Expand Down

0 comments on commit 0953afb

Please sign in to comment.