diff --git a/NEWS.md b/NEWS.md index 7aa4128f..8dfa7b15 100644 --- a/NEWS.md +++ b/NEWS.md @@ -3,7 +3,9 @@ Red Panda C++ Version 2.13 - fix: Only C/C++/GAS files can set breakpoints. - Enhancement: Don't show breakpoints/watch related menuitems in context menu for non-C/C++/GAS files. - Enhancement: Disable reformat code for non-C/C++ files. - - Enhancement: Support C11 ano + - Enhancement: Support C11 anonymous struct/union + - fix: Can't debug when debug a file while other file has breakpoints + - change: Don't save breakpoints for non-project files Red Panda C++ Version 2.12 diff --git a/RedPandaIDE/debugger.cpp b/RedPandaIDE/debugger.cpp index d43496ae..c312bf23 100644 --- a/RedPandaIDE/debugger.cpp +++ b/RedPandaIDE/debugger.cpp @@ -71,9 +71,9 @@ Debugger::~Debugger() // delete mMemoryModel; } -bool Debugger::start(int compilerSetIndex, const QString& inferior, const QStringList& binDirs) +bool Debugger::start(int compilerSetIndex, const QString& inferior, const QStringList& binDirs, const QString& sourceFile) { - + mCurrentSourceFile = sourceFile; Settings::PCompilerSet compilerSet = pSettings->compilerSets().getSet(compilerSetIndex); if (!compilerSet) { compilerSet = pSettings->compilerSets().defaultSet(); @@ -218,6 +218,7 @@ void Debugger::stop() { } mReader->stopDebug(); } + mCurrentSourceFile=""; } void Debugger::cleanUpReader() { @@ -347,7 +348,11 @@ void Debugger::addBreakpoint(int line, const QString &filename, bool forProject) bp->timestamp = QDateTime::currentMSecsSinceEpoch(); mBreakpointModel->addBreakpoint(bp,forProject); if (mExecuting) { - sendBreakpointCommand(bp); + if (forProject && mBreakpointModel->isForProject()) { + sendBreakpointCommand(bp); + } else if (filename == mCurrentSourceFile) { + sendBreakpointCommand(bp); + } } } @@ -430,7 +435,11 @@ void Debugger::setBreakPointCondition(int index, const QString &condition, bool void Debugger::sendAllBreakpointsToDebugger() { for (PBreakpoint breakpoint:mBreakpointModel->breakpoints(mBreakpointModel->isForProject())) { - sendBreakpointCommand(breakpoint); + if (mBreakpointModel->isForProject()) { + sendBreakpointCommand(breakpoint); + } else if (breakpoint->filename == mCurrentSourceFile) { + sendBreakpointCommand(breakpoint); + } } } @@ -747,7 +756,9 @@ void Debugger::save(const QString &filename, const QString& projectFolder) QJsonObject rootObj; rootObj["timestamp"] = QString("%1").arg(saveTimestamp); - rootObj["breakpoints"] = mBreakpointModel->toJson(projectFolder); + if (forProject) { + rootObj["breakpoints"] = mBreakpointModel->toJson(projectFolder); + } rootObj["watchvars"] = mWatchModel->toJson(forProject); QJsonDocument doc; doc.setObject(rootObj); diff --git a/RedPandaIDE/debugger.h b/RedPandaIDE/debugger.h index 9361c600..e6d9d791 100644 --- a/RedPandaIDE/debugger.h +++ b/RedPandaIDE/debugger.h @@ -307,7 +307,7 @@ public: explicit Debugger(QObject *parent = nullptr); ~Debugger(); // Play/pause - bool start(int compilerSetIndex, const QString& inferior, const QStringList& binDirs); + bool start(int compilerSetIndex, const QString& inferior, const QStringList& binDirs, const QString& sourceFile=QString()); void sendCommand(const QString& command, const QString& params, DebugCommandSource source = DebugCommandSource::Other); bool commandRunning(); @@ -415,6 +415,7 @@ private: int mLeftPageIndexBackup; qint64 mLastLoadtime; qint64 mProjectLastLoadtime; + QString mCurrentSourceFile; }; class DebugTarget: public QThread { diff --git a/RedPandaIDE/editor.cpp b/RedPandaIDE/editor.cpp index 1423346f..5769b9de 100644 --- a/RedPandaIDE/editor.cpp +++ b/RedPandaIDE/editor.cpp @@ -1034,7 +1034,7 @@ void Editor::onGutterPaint(QPainter &painter, int aLine, int X, int Y) } else { icon = pIconsManager->getPixmap(IconsManager::GUTTER_SYNTAX_WARNING); } - } else if (hasBookmark(aLine)) { + } else if (hasBookmark(aLine)) { icon = pIconsManager->getPixmap(IconsManager::GUTTER_BOOKMARK); } } @@ -4810,7 +4810,7 @@ void Editor::reformat(bool doReparse) } #endif //we must remove all breakpoints and syntax issues - onLinesDeleted(1,document()->count()); +// onLinesDeleted(1,document()->count()); QByteArray content = text().toUtf8(); QStringList args = pSettings->codeFormatter().getArguments(); //qDebug()<start(pSettings->compilerSets().defaultIndex(),filePath, binDirs)) + if (!mDebugger->start(pSettings->compilerSets().defaultIndex(),filePath, binDirs,e->filename())) return; mDebugger->sendCommand("-file-exec-and-symbols", QString("\"%1\"").arg(filePath)); }