- enhancement: project and non-project files use different breakpoint and watchvar view (auto switch when not debugging and editor switched)

- enhancement: save project's breakpoint and watchvar in it's own debug file.
  - enhancement: delete a watch expression don't reload who watch var view
This commit is contained in:
Roy Qu 2022-10-16 23:10:57 +08:00
parent 7883397409
commit 984d10eaf1
12 changed files with 633 additions and 392 deletions

View File

@ -16,7 +16,9 @@ Red Panda C++ Version 1.5
- fix: icons in options dialogs not correctly updated when change icon set - fix: icons in options dialogs not correctly updated when change icon set
- enhancement: set compilation stage in the options / compiler set pages - enhancement: set compilation stage in the options / compiler set pages
- enhancement: set custom compilation output suffix in the options / compiler set pages - enhancement: set custom compilation output suffix in the options / compiler set pages
- enhancement: project and non-project files use different breakpoint and watchvar view (auto switch when not debugging and editor switched)
- enhancement: save project's breakpoint and watchvar in it's own debug file.
- enhancement: delete a watch expression don't reload who watch var view
Red Panda C++ Version 1.4 Red Panda C++ Version 1.4

File diff suppressed because it is too large Load Diff

View File

@ -56,7 +56,8 @@ struct WatchVar {
QString type; QString type;
int numChild; int numChild;
QList<PWatchVar> children; QList<PWatchVar> children;
WatchVar * parent; //use raw point to prevent circular-reference std::weak_ptr<WatchVar> parent; //use raw point to prevent circular-reference
qint64 timestamp;
}; };
enum class BreakpointType { enum class BreakpointType {
@ -75,10 +76,20 @@ struct Breakpoint {
QString condition; QString condition;
bool enabled; bool enabled;
BreakpointType breakpointType; BreakpointType breakpointType;
qint64 timestamp;
}; };
using PBreakpoint = std::shared_ptr<Breakpoint>; using PBreakpoint = std::shared_ptr<Breakpoint>;
struct DebugConfig {
QList<PBreakpoint> breakpoints;
QList<PWatchVar> watchVars;
qint64 timestamp;
};
using PDebugConfig=std::shared_ptr<DebugConfig>;
struct Trace { struct Trace {
QString funcname; QString funcname;
QString filename; QString filename;
@ -105,6 +116,8 @@ private:
QHash<int,QString> mRegisterValues; QHash<int,QString> mRegisterValues;
}; };
class Debugger;
class BreakpointModel: public QAbstractTableModel { class BreakpointModel: public QAbstractTableModel {
Q_OBJECT Q_OBJECT
// QAbstractItemModel interface // QAbstractItemModel interface
@ -114,21 +127,34 @@ public:
int columnCount(const QModelIndex &parent) const override; int columnCount(const QModelIndex &parent) const override;
QVariant data(const QModelIndex &index, int role) const override; QVariant data(const QModelIndex &index, int role) const override;
QVariant headerData(int section, Qt::Orientation orientation, int role) const override; QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
void addBreakpoint(PBreakpoint p); void addBreakpoint(PBreakpoint p, bool forProject);
void clear(); void clear(bool forProject);
void removeBreakpoint(int index); void removeBreakpoint(int index, bool forProject);
PBreakpoint setBreakPointCondition(int index, const QString& condition); PBreakpoint setBreakPointCondition(int index, const QString& condition, bool forProject);
const QList<PBreakpoint>& breakpoints() const; const QList<PBreakpoint>& breakpoints(bool forProject) const {
PBreakpoint breakpoint(int index) const; return forProject?mProjectBreakpoints:mBreakpoints;
void save(const QString& filename); }
void load(const QString& filename);
PBreakpoint breakpoint(int index, bool forProject) const;
public slots: public slots:
void updateBreakpointNumber(const QString& filename, int line, int number); void updateBreakpointNumber(const QString& filename, int line, int number);
void invalidateAllBreakpointNumbers(); // call this when gdb is stopped void invalidateAllBreakpointNumbers(); // call this when gdb is stopped
void onFileDeleteLines(const QString& filename, int startLine, int count); void onFileDeleteLines(const QString& filename, int startLine, int count, bool forProject);
void onFileInsertLines(const QString& filename, int startLine, int count); void onFileInsertLines(const QString& filename, int startLine, int count, bool forProject);
private: private:
QList<PBreakpoint> mList; bool isForProject() const;
void setIsForProject(bool newIsForProject);
QList<PBreakpoint> loadJson(const QJsonArray& jsonArray, qint64 criteriaTime);
QJsonArray toJson(const QString& projectFolder);
void setBreakpoints(const QList<PBreakpoint>& list, bool forProject);
private:
QList<PBreakpoint> mBreakpoints;
QList<PBreakpoint> mProjectBreakpoints;
bool mIsForProject;
friend class Debugger;
}; };
class BacktraceModel : public QAbstractTableModel { class BacktraceModel : public QAbstractTableModel {
@ -164,11 +190,12 @@ public:
int rowCount(const QModelIndex &parent = QModelIndex()) const override; int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override; int columnCount(const QModelIndex &parent = QModelIndex()) const override;
bool hasChildren(const QModelIndex &parent) const override; bool hasChildren(const QModelIndex &parent) const override;
void addWatchVar(PWatchVar watchVar); QModelIndex index(PWatchVar var) const;
QModelIndex index(WatchVar* pVar) const;
void removeWatchVar(const QString& expression); void removeWatchVar(const QString& expression);
void removeWatchVar(const QModelIndex& index); void removeWatchVar(const QModelIndex& index);
void clear(); void clear();
const QList<PWatchVar>& watchVars();
PWatchVar findWatchVar(const QModelIndex& index); PWatchVar findWatchVar(const QModelIndex& index);
PWatchVar findWatchVar(const QString& expr); PWatchVar findWatchVar(const QString& expr);
void resetAllVarInfos(); void resetAllVarInfos();
@ -176,8 +203,6 @@ public:
void beginUpdate(); void beginUpdate();
void endUpdate(); void endUpdate();
void notifyUpdated(PWatchVar var); void notifyUpdated(PWatchVar var);
void save(const QString& filename);
void load(const QString& filename);
signals: signals:
void setWatchVarValue(const QString& name, const QString& value); void setWatchVarValue(const QString& name, const QString& value);
public slots: public slots:
@ -200,17 +225,30 @@ public slots:
signals: signals:
void fetchChildren(const QString& name); void fetchChildren(const QString& name);
private: private:
QModelIndex index(PWatchVar var) const; bool isForProject() const;
QModelIndex index(WatchVar* pVar) const; void setIsForProject(bool newIsForProject);
const QList<PWatchVar> &watchVars(bool forProject) const;
QJsonArray toJson(bool forProject);
QList<PWatchVar> loadJson(const QJsonArray &jsonArray, qint64 criteriaTimestamp);
const QList<PWatchVar> &watchVars() const;
void addWatchVar(PWatchVar watchVar);
void setWatchVars(const QList<PWatchVar> list, bool forProject);
private: private:
QList<PWatchVar> mWatchVars; QList<PWatchVar> mWatchVars;
QHash<QString,PWatchVar> mVarIndex; QList<PWatchVar> mProjectWatchVars;
QHash<QString,PWatchVar> mVarIndex; //var index is only valid for the current debugging session
int mUpdateCount; int mUpdateCount;
bool mIsForProject;
// QAbstractItemModel interface // QAbstractItemModel interface
public: public:
bool setData(const QModelIndex &index, const QVariant &value, int role) override; bool setData(const QModelIndex &index, const QVariant &value, int role) override;
Qt::ItemFlags flags(const QModelIndex &index) const override; Qt::ItemFlags flags(const QModelIndex &index) const override;
friend class Debugger;
}; };
struct MemoryLine { struct MemoryLine {
@ -267,20 +305,29 @@ public:
bool inferiorRunning(); bool inferiorRunning();
void interrupt(); void interrupt();
bool isForProject() const;
void setIsForProject(bool newIsForProject);
//breakpoints //breakpoints
void addBreakpoint(int line, const Editor* editor); void addBreakpoint(int line, const Editor* editor);
void addBreakpoint(int line, const QString& filename); void addBreakpoint(int line, const QString& filename, bool forProject);
void deleteBreakpoints(const QString& filename); void deleteBreakpoints(const QString& filename, bool forProject);
void deleteBreakpoints(const Editor* editor); void deleteBreakpoints(const Editor* editor);
void deleteBreakpoints(); void deleteBreakpoints(bool forProject);
void removeBreakpoint(int line, const Editor* editor); void removeBreakpoint(int line, const Editor* editor);
void removeBreakpoint(int line, const QString& filename); void removeBreakpoint(int line, const QString& filename, bool forProject);
void removeBreakpoint(int index); void removeBreakpoint(int index, bool forProject);
PBreakpoint breakpointAt(int line, const QString& filename, int &index); PBreakpoint breakpointAt(int line, const QString &filename, int *index, bool forProject);
PBreakpoint breakpointAt(int line, const Editor* editor, int &index); PBreakpoint breakpointAt(int line, const Editor *editor, int *index);
void setBreakPointCondition(int index, const QString& condition); void setBreakPointCondition(int index, const QString& condition, bool forProject);
void sendAllBreakpointsToDebugger(); void sendAllBreakpointsToDebugger();
void saveForNonproject(const QString &filename);
void saveForProject(const QString &filename, const QString &projectFolder);
void loadForNonproject(const QString &filename);
void loadForProject(const QString& filename, const QString& projectFolder);
//watch vars //watch vars
void addWatchVar(const QString& expression); void addWatchVar(const QString& expression);
void modifyWatchVarExpression(const QString& oldExpr, const QString& newExpr); void modifyWatchVarExpression(const QString& oldExpr, const QString& newExpr);
@ -292,18 +339,18 @@ public:
PWatchVar watchVarAt(const QModelIndex& index); PWatchVar watchVarAt(const QModelIndex& index);
// void notifyWatchVarUpdated(PWatchVar var); // void notifyWatchVarUpdated(PWatchVar var);
BacktraceModel* backtraceModel(); std::shared_ptr<BacktraceModel> backtraceModel();
BreakpointModel* breakpointModel(); std::shared_ptr<BreakpointModel> breakpointModel();
bool executing() const; bool executing() const;
int leftPageIndexBackup() const; int leftPageIndexBackup() const;
void setLeftPageIndexBackup(int leftPageIndexBackup); void setLeftPageIndexBackup(int leftPageIndexBackup);
WatchModel *watchModel() const; std::shared_ptr<WatchModel> watchModel() const;
RegisterModel *registerModel() const; std::shared_ptr<RegisterModel> registerModel() const;
MemoryModel *memoryModel() const; std::shared_ptr<MemoryModel> memoryModel() const;
bool forceUTF8() const; bool forceUTF8() const;
void setForceUTF8(bool newForceUTF8); void setForceUTF8(bool newForceUTF8);
@ -320,8 +367,10 @@ private:
void sendWatchCommand(PWatchVar var); void sendWatchCommand(PWatchVar var);
void sendRemoveWatchCommand(PWatchVar var); void sendRemoveWatchCommand(PWatchVar var);
void sendBreakpointCommand(PBreakpoint breakpoint); void sendBreakpointCommand(PBreakpoint breakpoint);
void sendClearBreakpointCommand(int index); void sendClearBreakpointCommand(int index, bool forProject);
void sendClearBreakpointCommand(PBreakpoint breakpoint); void sendClearBreakpointCommand(PBreakpoint breakpoint);
void save(const QString& filename, const QString& projectFolder);
PDebugConfig load(const QString& filename, bool forProject);
private slots: private slots:
void syncFinishedParsing(); void syncFinishedParsing();
@ -339,15 +388,17 @@ private slots:
private: private:
bool mExecuting; bool mExecuting;
bool mCommandChanged; bool mCommandChanged;
BreakpointModel *mBreakpointModel; std::shared_ptr<BreakpointModel> mBreakpointModel;
BacktraceModel *mBacktraceModel; std::shared_ptr<BacktraceModel> mBacktraceModel;
WatchModel *mWatchModel; std::shared_ptr<WatchModel> mWatchModel;
RegisterModel *mRegisterModel; std::shared_ptr<RegisterModel> mRegisterModel;
MemoryModel *mMemoryModel; std::shared_ptr<MemoryModel> mMemoryModel;
DebugReader *mReader; DebugReader *mReader;
DebugTarget *mTarget; DebugTarget *mTarget;
bool mForceUTF8; bool mForceUTF8;
int mLeftPageIndexBackup; int mLeftPageIndexBackup;
qint64 mLastLoadtime;
qint64 mProjectLastLoadtime;
}; };
class DebugTarget: public QThread { class DebugTarget: public QThread {

View File

@ -1291,7 +1291,7 @@ void Editor::showEvent(QShowEvent */*event*/)
resetCppParser(mParser); resetCppParser(mParser);
reparse(); reparse();
} }
pMainWindow->debugger()->setIsForProject(inProject());
pMainWindow->bookmarkModel()->setIsForProject(inProject()); pMainWindow->bookmarkModel()->setIsForProject(inProject());
// if (pSettings->codeCompletion().clearWhenEditorHidden() // if (pSettings->codeCompletion().clearWhenEditorHidden()
// && !inProject()) { // && !inProject()) {
@ -1696,7 +1696,7 @@ void Editor::onTipEvalValueReady(const QString& value)
void Editor::onLinesDeleted(int first, int count) void Editor::onLinesDeleted(int first, int count)
{ {
pMainWindow->caretList().linesDeleted(this,first,count); pMainWindow->caretList().linesDeleted(this,first,count);
pMainWindow->debugger()->breakpointModel()->onFileDeleteLines(mFilename,first,count); pMainWindow->debugger()->breakpointModel()->onFileDeleteLines(mFilename,first,count,inProject());
pMainWindow->bookmarkModel()->onFileDeleteLines(mFilename,first,count, inProject()); pMainWindow->bookmarkModel()->onFileDeleteLines(mFilename,first,count, inProject());
resetBreakpoints(); resetBreakpoints();
resetBookmarks(); resetBookmarks();
@ -1708,7 +1708,7 @@ void Editor::onLinesDeleted(int first, int count)
void Editor::onLinesInserted(int first, int count) void Editor::onLinesInserted(int first, int count)
{ {
pMainWindow->caretList().linesInserted(this,first,count); pMainWindow->caretList().linesInserted(this,first,count);
pMainWindow->debugger()->breakpointModel()->onFileInsertLines(mFilename,first,count); pMainWindow->debugger()->breakpointModel()->onFileInsertLines(mFilename,first,count, inProject());
pMainWindow->bookmarkModel()->onFileInsertLines(mFilename,first,count, inProject()); pMainWindow->bookmarkModel()->onFileInsertLines(mFilename,first,count, inProject());
resetBreakpoints(); resetBreakpoints();
resetBookmarks(); resetBookmarks();
@ -1756,7 +1756,7 @@ void Editor::resetBreakpoints()
{ {
mBreakpointLines.clear(); mBreakpointLines.clear();
foreach (const PBreakpoint& breakpoint, foreach (const PBreakpoint& breakpoint,
pMainWindow->debugger()->breakpointModel()->breakpoints()) { pMainWindow->debugger()->breakpointModel()->breakpoints(inProject())) {
if (breakpoint->filename == mFilename) { if (breakpoint->filename == mFilename) {
mBreakpointLines.insert(breakpoint->line); mBreakpointLines.insert(breakpoint->line);
} }
@ -4444,7 +4444,7 @@ void Editor::removeBreakpointFocus()
void Editor::modifyBreakpointProperty(int line) void Editor::modifyBreakpointProperty(int line)
{ {
int index; int index;
PBreakpoint breakpoint = pMainWindow->debugger()->breakpointAt(line,this,index); PBreakpoint breakpoint = pMainWindow->debugger()->breakpointAt(line,this,&index);
if (!breakpoint) if (!breakpoint)
return; return;
bool isOk; bool isOk;
@ -4454,7 +4454,7 @@ void Editor::modifyBreakpointProperty(int line)
QLineEdit::Normal, QLineEdit::Normal,
breakpoint->condition,&isOk); breakpoint->condition,&isOk);
if (isOk) { if (isOk) {
pMainWindow->debugger()->setBreakPointCondition(index,s); pMainWindow->debugger()->setBreakPointCondition(index,s,inProject());
} }
} }

View File

@ -163,34 +163,26 @@ MainWindow::MainWindow(QWidget *parent)
mDebugger = std::make_shared<Debugger>(); mDebugger = std::make_shared<Debugger>();
m=ui->tblBreakpoints->selectionModel(); m=ui->tblBreakpoints->selectionModel();
ui->tblBreakpoints->setModel(mDebugger->breakpointModel()); ui->tblBreakpoints->setModel(mDebugger->breakpointModel().get());
delete m; delete m;
m=ui->tblStackTrace->selectionModel(); m=ui->tblStackTrace->selectionModel();
ui->tblStackTrace->setModel(mDebugger->backtraceModel()); ui->tblStackTrace->setModel(mDebugger->backtraceModel().get());
delete m; delete m;
m=ui->watchView->selectionModel(); m=ui->watchView->selectionModel();
ui->watchView->setModel(mDebugger->watchModel()); ui->watchView->setModel(mDebugger->watchModel().get());
delete m; delete m;
m=ui->tblMemoryView->selectionModel(); m=ui->tblMemoryView->selectionModel();
ui->tblMemoryView->setModel(mDebugger->memoryModel()); ui->tblMemoryView->setModel(mDebugger->memoryModel().get());
delete m; delete m;
ui->tblMemoryView->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); ui->tblMemoryView->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
try { try {
mDebugger->breakpointModel()->load(includeTrailingPathDelimiter(pSettings->dirs().config()) mDebugger->loadForNonproject(includeTrailingPathDelimiter(pSettings->dirs().config())
+DEV_BREAKPOINTS_FILE); +DEV_DEBUGGER_FILE);
} catch (FileError &e) {
QMessageBox::warning(nullptr,
tr("Error"),
e.reason());
}
try {
mDebugger->watchModel()->load(includeTrailingPathDelimiter(pSettings->dirs().config())
+DEV_WATCH_FILE);
} catch (FileError &e) { } catch (FileError &e) {
QMessageBox::warning(nullptr, QMessageBox::warning(nullptr,
tr("Error"), tr("Error"),
@ -1311,6 +1303,10 @@ void MainWindow::openProject(const QString &filename, bool openFiles)
mBookmarkModel->loadProjectBookmarks( mBookmarkModel->loadProjectBookmarks(
changeFileExt(mProject->filename(), PROJECT_BOOKMARKS_EXT), changeFileExt(mProject->filename(), PROJECT_BOOKMARKS_EXT),
mProject->directory()); mProject->directory());
mDebugger->setIsForProject(true);
mDebugger->loadForProject(
changeFileExt(mProject->filename(), PROJECT_DEBUG_EXT),
mProject->directory());
if (openFiles) { if (openFiles) {
PProjectUnit unit = mProject->doAutoOpen(); PProjectUnit unit = mProject->doAutoOpen();
@ -4068,21 +4064,21 @@ void MainWindow::onBreakpointRemove()
{ {
int index =ui->tblBreakpoints->selectionModel()->currentIndex().row(); int index =ui->tblBreakpoints->selectionModel()->currentIndex().row();
PBreakpoint breakpoint = debugger()->breakpointModel()->breakpoint(index); PBreakpoint breakpoint = debugger()->breakpointModel()->breakpoint(index, debugger()->isForProject());
if (breakpoint) { if (breakpoint) {
Editor * e = mEditorList->getOpenedEditorByFilename(breakpoint->filename); Editor * e = mEditorList->getOpenedEditorByFilename(breakpoint->filename);
if (e) { if (e) {
if (e->hasBreakpoint(breakpoint->line)) if (e->hasBreakpoint(breakpoint->line))
e->toggleBreakpoint(breakpoint->line); e->toggleBreakpoint(breakpoint->line);
} else { } else {
debugger()->breakpointModel()->removeBreakpoint(index); debugger()->breakpointModel()->removeBreakpoint(index,debugger()->isForProject());
} }
} }
} }
void MainWindow::onBreakpointViewRemoveAll() void MainWindow::onBreakpointViewRemoveAll()
{ {
pMainWindow->debugger()->deleteBreakpoints(); debugger()->deleteBreakpoints(debugger()->isForProject());
for (int i=0;i<mEditorList->pageCount();i++) { for (int i=0;i<mEditorList->pageCount();i++) {
Editor * e = (*(mEditorList))[i]; Editor * e = (*(mEditorList))[i];
if (e) { if (e) {
@ -4096,7 +4092,8 @@ void MainWindow::onBreakpointViewProperty()
int index =ui->tblBreakpoints->selectionModel()->currentIndex().row(); int index =ui->tblBreakpoints->selectionModel()->currentIndex().row();
PBreakpoint breakpoint = debugger()->breakpointModel()->breakpoint( PBreakpoint breakpoint = debugger()->breakpointModel()->breakpoint(
index index,
debugger()->isForProject()
); );
if (breakpoint) { if (breakpoint) {
bool isOk; bool isOk;
@ -4106,7 +4103,7 @@ void MainWindow::onBreakpointViewProperty()
QLineEdit::Normal, QLineEdit::Normal,
breakpoint->condition,&isOk); breakpoint->condition,&isOk);
if (isOk) { if (isOk) {
pMainWindow->debugger()->setBreakPointCondition(index,s); pMainWindow->debugger()->setBreakPointCondition(index,s,debugger()->isForProject());
} }
} }
} }
@ -4373,6 +4370,10 @@ void MainWindow::closeProject(bool refreshEditor)
changeFileExt(mProject->filename(), PROJECT_BOOKMARKS_EXT), changeFileExt(mProject->filename(), PROJECT_BOOKMARKS_EXT),
mProject->directory()); mProject->directory());
mDebugger->saveForProject(
changeFileExt(mProject->filename(), PROJECT_DEBUG_EXT),
mProject->directory());
mClassBrowserModel.beginUpdate(); mClassBrowserModel.beginUpdate();
// Remember it // Remember it
pSettings->history().addToOpenedProjects(mProject->filename()); pSettings->history().addToOpenedProjects(mProject->filename());
@ -4394,6 +4395,7 @@ void MainWindow::closeProject(bool refreshEditor)
if (!mQuitting) { if (!mQuitting) {
mBookmarkModel->setIsForProject(false); mBookmarkModel->setIsForProject(false);
mDebugger->setIsForProject(false);
// Clear error browser // Clear error browser
clearIssues(); clearIssues();
updateProjectView(); updateProjectView();
@ -4610,10 +4612,10 @@ void MainWindow::closeEvent(QCloseEvent *event) {
e.reason()); e.reason());
} }
if (pSettings->debugger().autosaveBreakpoints()) { if (pSettings->debugger().autosave()) {
try { try {
mDebugger->breakpointModel()->save(includeTrailingPathDelimiter(pSettings->dirs().config()) mDebugger->saveForNonproject(includeTrailingPathDelimiter(pSettings->dirs().config())
+DEV_BREAKPOINTS_FILE); +DEV_DEBUGGER_FILE);
} catch (FileError& e) { } catch (FileError& e) {
QMessageBox::warning(nullptr, QMessageBox::warning(nullptr,
tr("Save Error"), tr("Save Error"),
@ -4621,20 +4623,7 @@ void MainWindow::closeEvent(QCloseEvent *event) {
} }
} else } else
removeFile(includeTrailingPathDelimiter(pSettings->dirs().config()) removeFile(includeTrailingPathDelimiter(pSettings->dirs().config())
+DEV_BREAKPOINTS_FILE); +DEV_DEBUGGER_FILE);
if (pSettings->debugger().autosaveWatches()) {
try {
mDebugger->watchModel()->save(includeTrailingPathDelimiter(pSettings->dirs().config())
+DEV_WATCH_FILE);
} catch (FileError& e) {
QMessageBox::warning(nullptr,
tr("Save Error"),
e.reason());
}
} else
removeFile(includeTrailingPathDelimiter(pSettings->dirs().config())
+DEV_WATCH_FILE);
} }
if (!mShouldRemoveAllSettings && pSettings->editor().autoLoadLastFiles()) { if (!mShouldRemoveAllSettings && pSettings->editor().autoLoadLastFiles()) {
@ -5289,20 +5278,21 @@ bool MainWindow::debugInferiorhasBreakpoint()
Editor * e = mEditorList->getEditor(); Editor * e = mEditorList->getEditor();
if (e==nullptr) if (e==nullptr)
return false; return false;
if (!e->inProject()) { for (const PBreakpoint& breakpoint:mDebugger->breakpointModel()->breakpoints(e->inProject())) {
for (const PBreakpoint& breakpoint:mDebugger->breakpointModel()->breakpoints()) {
if (e->filename() == breakpoint->filename) { if (e->filename() == breakpoint->filename) {
return true; return true;
} }
} }
} else { // if (!e->inProject()) {
for (const PBreakpoint& breakpoint:mDebugger->breakpointModel()->breakpoints()) {
Editor* e1 = mEditorList->getOpenedEditorByFilename(breakpoint->filename); // } else {
if (e1 && e1->inProject()) { // for (const PBreakpoint& breakpoint:mDebugger->breakpointModel()->breakpoints(e->inProject())) {
return true; // Editor* e1 = mEditorList->getOpenedEditorByFilename(breakpoint->filename);
} // if (e1 && e1->inProject()) {
} // return true;
} // }
// }
// }
return false; return false;
} }
@ -5875,7 +5865,9 @@ void MainWindow::on_tblStackTrace_doubleClicked(const QModelIndex &index)
void MainWindow::on_tblBreakpoints_doubleClicked(const QModelIndex &index) void MainWindow::on_tblBreakpoints_doubleClicked(const QModelIndex &index)
{ {
PBreakpoint breakpoint = mDebugger->breakpointModel()->breakpoint(index.row()); PBreakpoint breakpoint = mDebugger->breakpointModel()->breakpoint(
index.row(),
mDebugger->isForProject());
if (breakpoint) { if (breakpoint) {
Editor * e = mEditorList->getEditorByFilename(breakpoint->filename); Editor * e = mEditorList->getEditorByFilename(breakpoint->filename);
if (e) { if (e) {

View File

@ -3532,16 +3532,6 @@ void Settings::Debugger::setSkipCustomLibraries(bool newSkipCustomLibraries)
mSkipCustomLibraries = newSkipCustomLibraries; mSkipCustomLibraries = newSkipCustomLibraries;
} }
bool Settings::Debugger::autosaveWatches() const
{
return mAutosaveWatches;
}
void Settings::Debugger::setAutosaveWatches(bool newAutosaveWatches)
{
mAutosaveWatches = newAutosaveWatches;
}
bool Settings::Debugger::openCPUInfoWhenSignaled() const bool Settings::Debugger::openCPUInfoWhenSignaled() const
{ {
return mOpenCPUInfoWhenSignaled; return mOpenCPUInfoWhenSignaled;
@ -3592,14 +3582,14 @@ void Settings::Debugger::setMemoryViewColumns(int newMemoryViewColumns)
mMemoryViewColumns = newMemoryViewColumns; mMemoryViewColumns = newMemoryViewColumns;
} }
bool Settings::Debugger::autosaveBreakpoints() const bool Settings::Debugger::autosave() const
{ {
return mAutosaveBreakpoints; return mAutosave;
} }
void Settings::Debugger::setAutosaveBreakpoints(bool newAutosaveBreakpoints) void Settings::Debugger::setAutosave(bool newAutosave)
{ {
mAutosaveBreakpoints = newAutosaveBreakpoints; mAutosave = newAutosave;
} }
bool Settings::Debugger::useIntelStyle() const bool Settings::Debugger::useIntelStyle() const
@ -3644,8 +3634,7 @@ void Settings::Debugger::doSave()
saveValue("skip_system_lib", mSkipSystemLibraries); saveValue("skip_system_lib", mSkipSystemLibraries);
saveValue("skip_project_lib", mSkipProjectLibraries); saveValue("skip_project_lib", mSkipProjectLibraries);
saveValue("skip_custom_lib", mSkipCustomLibraries); saveValue("skip_custom_lib", mSkipCustomLibraries);
saveValue("autosave_breakpoints",mAutosaveBreakpoints); saveValue("autosave",mAutosave);
saveValue("autosave_watches",mAutosaveWatches);
saveValue("open_cpu_info_when_signaled",mOpenCPUInfoWhenSignaled); saveValue("open_cpu_info_when_signaled",mOpenCPUInfoWhenSignaled);
saveValue("use_gdb_server", mUseGDBServer); saveValue("use_gdb_server", mUseGDBServer);
saveValue("gdb_server_port",mGDBServerPort); saveValue("gdb_server_port",mGDBServerPort);
@ -3670,8 +3659,7 @@ void Settings::Debugger::doLoad()
mSkipSystemLibraries = boolValue("skip_system_lib",true); mSkipSystemLibraries = boolValue("skip_system_lib",true);
mSkipProjectLibraries = boolValue("skip_project_lib",true); mSkipProjectLibraries = boolValue("skip_project_lib",true);
mSkipCustomLibraries = boolValue("skip_custom_lib",false); mSkipCustomLibraries = boolValue("skip_custom_lib",false);
mAutosaveBreakpoints = boolValue("autosave_breakpoints",true); mAutosave = boolValue("autosave",true);
mAutosaveWatches = boolValue("autosave_watches",true);
mOpenCPUInfoWhenSignaled = boolValue("open_cpu_info_when_signaled",true); mOpenCPUInfoWhenSignaled = boolValue("open_cpu_info_when_signaled",true);
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
mUseGDBServer = boolValue("use_gdb_server", false); mUseGDBServer = boolValue("use_gdb_server", false);

View File

@ -1126,12 +1126,6 @@ public:
bool skipCustomLibraries() const; bool skipCustomLibraries() const;
void setSkipCustomLibraries(bool newSkipCustomLibraries); void setSkipCustomLibraries(bool newSkipCustomLibraries);
bool autosaveBreakpoints() const;
void setAutosaveBreakpoints(bool newAutosaveBreakpoints);
bool autosaveWatches() const;
void setAutosaveWatches(bool newAutosaveWatches);
bool openCPUInfoWhenSignaled() const; bool openCPUInfoWhenSignaled() const;
void setOpenCPUInfoWhenSignaled(bool newOpenCPUInfoWhenSignaled); void setOpenCPUInfoWhenSignaled(bool newOpenCPUInfoWhenSignaled);
@ -1146,6 +1140,9 @@ public:
int memoryViewColumns() const; int memoryViewColumns() const;
void setMemoryViewColumns(int newMemoryViewColumns); void setMemoryViewColumns(int newMemoryViewColumns);
bool autosave() const;
void setAutosave(bool newAutosave);
private: private:
bool mEnableDebugConsole; bool mEnableDebugConsole;
bool mShowDetailLog; bool mShowDetailLog;
@ -1157,8 +1154,7 @@ public:
bool mSkipSystemLibraries; bool mSkipSystemLibraries;
bool mSkipProjectLibraries; bool mSkipProjectLibraries;
bool mSkipCustomLibraries; bool mSkipCustomLibraries;
bool mAutosaveBreakpoints; bool mAutosave;
bool mAutosaveWatches;
bool mOpenCPUInfoWhenSignaled; bool mOpenCPUInfoWhenSignaled;
bool mUseGDBServer; bool mUseGDBServer;
int mGDBServerPort; int mGDBServerPort;

View File

@ -48,8 +48,7 @@ void DebugGeneralWidget::doLoad()
ui->chkSkipSystemLib->setChecked(pSettings->debugger().skipSystemLibraries()); ui->chkSkipSystemLib->setChecked(pSettings->debugger().skipSystemLibraries());
ui->chkSkipProjectLib->setChecked(pSettings->debugger().skipProjectLibraries()); ui->chkSkipProjectLib->setChecked(pSettings->debugger().skipProjectLibraries());
ui->chkSkipCustomLib->setChecked(pSettings->debugger().skipCustomLibraries()); ui->chkSkipCustomLib->setChecked(pSettings->debugger().skipCustomLibraries());
ui->chkAutosaveBreakpoints->setChecked(pSettings->debugger().autosaveBreakpoints()); ui->chkAutosave->setChecked(pSettings->debugger().autosave());
ui->chkAutosaveWatches->setChecked(pSettings->debugger().autosaveWatches());
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
ui->grpUseGDBServer->setCheckable(true); ui->grpUseGDBServer->setCheckable(true);
ui->grpUseGDBServer->setChecked(pSettings->debugger().useGDBServer()); ui->grpUseGDBServer->setChecked(pSettings->debugger().useGDBServer());
@ -72,8 +71,7 @@ void DebugGeneralWidget::doSave()
pSettings->debugger().setSkipSystemLibraries(ui->chkSkipSystemLib->isChecked()); pSettings->debugger().setSkipSystemLibraries(ui->chkSkipSystemLib->isChecked());
pSettings->debugger().setSkipProjectLibraries(ui->chkSkipProjectLib->isChecked()); pSettings->debugger().setSkipProjectLibraries(ui->chkSkipProjectLib->isChecked());
pSettings->debugger().setSkipCustomLibraries(ui->chkSkipCustomLib->isChecked()); pSettings->debugger().setSkipCustomLibraries(ui->chkSkipCustomLib->isChecked());
pSettings->debugger().setAutosaveBreakpoints(ui->chkAutosaveBreakpoints->isChecked()); pSettings->debugger().setAutosave(ui->chkAutosave->isChecked());
pSettings->debugger().setAutosaveWatches(ui->chkAutosaveWatches->isChecked());
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
pSettings->debugger().setUseGDBServer(ui->grpUseGDBServer->isChecked()); pSettings->debugger().setUseGDBServer(ui->grpUseGDBServer->isChecked());
#endif #endif

View File

@ -318,16 +318,9 @@
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_3"> <layout class="QVBoxLayout" name="verticalLayout_3">
<item> <item>
<widget class="QCheckBox" name="chkAutosaveBreakpoints"> <widget class="QCheckBox" name="chkAutosave">
<property name="text"> <property name="text">
<string>Autosave breakpoints</string> <string>Autosave breakpoints and watches</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkAutosaveWatches">
<property name="text">
<string>Autosave watches</string>
</property> </property>
</widget> </widget>
</item> </item>

View File

@ -71,6 +71,7 @@
#define DEV_PROJECT_EXT "dev" #define DEV_PROJECT_EXT "dev"
#define PROJECT_BOOKMARKS_EXT "bookmarks" #define PROJECT_BOOKMARKS_EXT "bookmarks"
#define PROJECT_DEBUG_EXT "debug"
#define RC_EXT "rc" #define RC_EXT "rc"
#define RES_EXT "res" #define RES_EXT "res"
#define H_EXT "h" #define H_EXT "h"
@ -89,8 +90,7 @@
#define DEV_SHORTCUT_FILE "shortcuts.json" #define DEV_SHORTCUT_FILE "shortcuts.json"
#define DEV_TOOLS_FILE "tools.json" #define DEV_TOOLS_FILE "tools.json"
#define DEV_BOOKMARK_FILE "bookmarks.json" #define DEV_BOOKMARK_FILE "bookmarks.json"
#define DEV_BREAKPOINTS_FILE "breakpoints.json" #define DEV_DEBUGGER_FILE "debugger.json"
#define DEV_WATCH_FILE "watch.json"
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
# define PATH_SENSITIVITY Qt::CaseInsensitive # define PATH_SENSITIVITY Qt::CaseInsensitive

View File

@ -182,7 +182,9 @@ void BookmarkModel::loadBookmarks(const QString &filename)
{ {
if (!mIsForProject) if (!mIsForProject)
beginResetModel(); beginResetModel();
mBookmarks = load(filename,0,&mLastLoadBookmarksTimestamp); qint64 t;
mLastLoadBookmarksTimestamp = QDateTime::currentMSecsSinceEpoch();
mBookmarks = load(filename,0,&t);
if (!mIsForProject) if (!mIsForProject)
endResetModel(); endResetModel();
} }
@ -227,7 +229,6 @@ void BookmarkModel::save(const QString &filename, const QString& projectFolder)
if (pTemp->timestamp<=bookmark->timestamp) if (pTemp->timestamp<=bookmark->timestamp)
compareHash.insert(key,bookmark); compareHash.insert(key,bookmark);
} }
compareHash.insert(key,bookmark);
} }
QList<PBookmark> saveList; QList<PBookmark> saveList;
foreach (const PBookmark& bookmark, compareHash) { foreach (const PBookmark& bookmark, compareHash) {
@ -320,7 +321,9 @@ void BookmarkModel::loadProjectBookmarks(const QString &filename, const QString&
{ {
if (mIsForProject) if (mIsForProject)
beginResetModel(); beginResetModel();
mProjectBookmarks = load(filename,0,&mLastLoadProjectBookmarksTimestamp); qint64 t;
mLastLoadProjectBookmarksTimestamp = QDateTime::currentMSecsSinceEpoch();
mProjectBookmarks = load(filename,0,&t);
QDir folder(projectFolder); QDir folder(projectFolder);
foreach (PBookmark bookmark, mProjectBookmarks) { foreach (PBookmark bookmark, mProjectBookmarks) {
bookmark->filename=folder.absoluteFilePath(bookmark->filename); bookmark->filename=folder.absoluteFilePath(bookmark->filename);

View File

@ -56,7 +56,7 @@ CPUDialog::CPUDialog(QWidget *parent) :
} }
resetEditorFont(screenDPI()); resetEditorFont(screenDPI());
QItemSelectionModel *m=ui->lstRegister->selectionModel(); QItemSelectionModel *m=ui->lstRegister->selectionModel();
ui->lstRegister->setModel(pMainWindow->debugger()->registerModel()); ui->lstRegister->setModel(pMainWindow->debugger()->registerModel().get());
delete m; delete m;
ui->rdIntel->setChecked(pSettings->debugger().useIntelStyle()); ui->rdIntel->setChecked(pSettings->debugger().useIntelStyle());