diff --git a/NEWS.md b/NEWS.md index afefa0ab..0487f441 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,6 +4,8 @@ Red Panda C++ Version 2.14 - fix: Enum value defines is not correctly parsed. - enhancement: Use differenct source file for each language in project templates - fix: Ctrl+click is too sensitive. + - enhancement: Remove all breakpoints for a closed non-project file. + - enhancement: Check and remove all non-exist breakpoints before debug a project Red Panda C++ Version 2.13 diff --git a/RedPandaIDE/debugger.cpp b/RedPandaIDE/debugger.cpp index c312bf23..10d7980c 100644 --- a/RedPandaIDE/debugger.cpp +++ b/RedPandaIDE/debugger.cpp @@ -377,7 +377,16 @@ void Debugger::deleteBreakpoints(bool forProject) mBreakpointModel->clear(forProject); // for (int i=mBreakpointModel->breakpoints().size()-1;i>=0;i--) { // removeBreakpoint(i); -// } + // } +} + +void Debugger::deleteInvalidProjectBreakpoints(const QSet unitFiles) +{ + for(int i=mBreakpointModel->breakpoints(true).count()-1;i>=0;i--) { + const PBreakpoint& bp=mBreakpointModel->breakpoint(i,true); + if (!unitFiles.contains(bp->filename)) + mBreakpointModel->removeBreakpoint(i, true); + } } void Debugger::removeBreakpoint(int line, const Editor *editor) diff --git a/RedPandaIDE/debugger.h b/RedPandaIDE/debugger.h index e6d9d791..2ff10aee 100644 --- a/RedPandaIDE/debugger.h +++ b/RedPandaIDE/debugger.h @@ -324,6 +324,7 @@ public: void deleteBreakpoints(const QString& filename, bool forProject); void deleteBreakpoints(const Editor* editor); void deleteBreakpoints(bool forProject); + void deleteInvalidProjectBreakpoints(const QSet unitFiles); void removeBreakpoint(int line, const Editor* editor); void removeBreakpoint(int line, const QString& filename, bool forProject); void removeBreakpoint(int index, bool forProject); diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index 2959dade..6472e685 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -2088,6 +2088,7 @@ void MainWindow::debug() QString filePath; QFileInfo debugFile; QStringList binDirs; + QSet unitFiles; switch(getCompileTarget()) { case CompileTarget::Project: compilerSet=pSettings->compilerSets().getSet(mProject->options().compilerSet); @@ -2175,6 +2176,10 @@ void MainWindow::debug() // mDebugger->setUseUTF8(e->fileEncoding() == ENCODING_UTF8 || e->fileEncoding() == ENCODING_UTF8_BOM); + foreach(const PProjectUnit& unit, mProject->unitList()) { + unitFiles.insert(unit->fileName()); + } + mDebugger->deleteInvalidProjectBreakpoints(unitFiles); if (!mDebugger->start(mProject->options().compilerSet, filePath, binDirs)) return; filePath.replace('\\','/');