debugger: Remove few redundant variables
Use the GUI widget states instead of instance variables
reflecting the widget state.
Fixes the case where pause state would be left on when
switching files, but the image would change to the last
frame of newly loaded image.
Review URL: https://codereview.chromium.org/810033004
diff --git a/debugger/QT/SkDebuggerGUI.cpp b/debugger/QT/SkDebuggerGUI.cpp
index 1d37c7d..1b5a366 100644
--- a/debugger/QT/SkDebuggerGUI.cpp
+++ b/debugger/QT/SkDebuggerGUI.cpp
@@ -62,10 +62,6 @@
, fMenuFile(this)
, fMenuNavigate(this)
, fMenuView(this)
- , fBreakpointsActivated(false)
- , fIndexStyleToggle(false)
- , fDeletesActivated(false)
- , fPause(false)
, fLoading(false)
{
setupUi(this);
@@ -123,26 +119,26 @@
}
void SkDebuggerGUI::actionBreakpoints() {
- fBreakpointsActivated = !fBreakpointsActivated;
+ bool breakpointsActivated = fActionBreakpoint.isChecked();
for (int row = 0; row < fListWidget.count(); row++) {
QListWidgetItem *item = fListWidget.item(row);
- item->setHidden(item->checkState() == Qt::Unchecked && fBreakpointsActivated);
+ item->setHidden(item->checkState() == Qt::Unchecked && breakpointsActivated);
}
}
void SkDebuggerGUI::actionToggleIndexStyle() {
- fIndexStyleToggle = !fIndexStyleToggle;
+ bool indexStyleToggle = fActionToggleIndexStyle.isChecked();
SkListWidget* list = (SkListWidget*) fListWidget.itemDelegate();
- list->setIndexStyle(fIndexStyleToggle ? SkListWidget::kIndex_IndexStyle :
- SkListWidget::kOffset_IndexStyle);
+ list->setIndexStyle(indexStyleToggle ? SkListWidget::kOffset_IndexStyle
+ : SkListWidget::kIndex_IndexStyle);
fListWidget.update();
}
void SkDebuggerGUI::showDeletes() {
- fDeletesActivated = !fDeletesActivated;
+ bool deletesActivated = fActionShowDeletes.isChecked();
for (int row = 0; row < fListWidget.count(); row++) {
QListWidgetItem *item = fListWidget.item(row);
- item->setHidden(fDebugger.isCommandVisible(row) && fDeletesActivated);
+ item->setHidden(fDebugger.isCommandVisible(row) && deletesActivated);
}
}
// This is a simplification of PictureBenchmark's run with the addition of
@@ -222,7 +218,7 @@
fDebugger.setCommandVisible(row, true);
fSkipCommands[row] = false;
}
- if (fPause) {
+ if (this->isPaused()) {
fCanvasWidget.drawTo(fPausedRow);
} else {
fCanvasWidget.drawTo(fListWidget.currentRow());
@@ -255,7 +251,7 @@
int currentRow = fListWidget.currentRow();
- if (fPause) {
+ if (this->isPaused()) {
fCanvasWidget.drawTo(fPausedRow);
} else {
fCanvasWidget.drawTo(currentRow);
@@ -402,9 +398,10 @@
}
void SkDebuggerGUI::pauseDrawing(bool isPaused) {
- fPause = isPaused;
fPausedRow = fListWidget.currentRow();
- fCanvasWidget.drawTo(fPausedRow);
+ if (!fLoading) {
+ fCanvasWidget.drawTo(fPausedRow);
+ }
}
void SkDebuggerGUI::registerListClick(QListWidgetItem *item) {
@@ -412,7 +409,7 @@
int currentRow = fListWidget.currentRow();
if (currentRow != -1) {
- if (!fPause) {
+ if (!this->isPaused()) {
fCanvasWidget.drawTo(currentRow);
}
const SkTDArray<SkString*> *currInfo = fDebugger.getCommandInfo(currentRow);
@@ -438,7 +435,7 @@
}
void SkDebuggerGUI::selectCommand(int command) {
- if (fPause) {
+ if (this->isPaused()) {
fListWidget.setCurrentRow(command);
}
}
@@ -485,9 +482,11 @@
fActionBreakpoint.setShortcut(QKeySequence(tr("Ctrl+B")));
fActionBreakpoint.setIcon(breakpoint);
fActionBreakpoint.setText("Breakpoints");
+ fActionBreakpoint.setCheckable(true);
fActionToggleIndexStyle.setShortcut(QKeySequence(tr("Ctrl+T")));
fActionToggleIndexStyle.setText("Toggle Index Style");
+ fActionToggleIndexStyle.setCheckable(true);
QIcon cancel;
cancel.addFile(QString::fromUtf8(":/reload.png"), QSize(),
@@ -565,6 +564,7 @@
fActionShowDeletes.setShortcut(QKeySequence(tr("Ctrl+X")));
fActionShowDeletes.setText("Deleted Commands");
+ fActionShowDeletes.setCheckable(true);
QIcon stepBack;
stepBack.addFile(QString::fromUtf8(":/previous.png"), QSize(),
@@ -722,8 +722,6 @@
fMenuBar.addAction(fMenuNavigate.menuAction());
fMenuBar.addAction(fMenuWindows.menuAction());
- fPause = false;
-
SkDebuggerGUI->setMenuBar(&fMenuBar);
QMetaObject::connectSlotsByName(SkDebuggerGUI);
}
@@ -784,6 +782,7 @@
fMenuView.setDisabled(false);
fActionSave.setDisabled(false);
fActionSaveAs.setDisabled(false);
+ fActionPause.setChecked(false);
fLoading = false;
actionPlay();
}
diff --git a/debugger/QT/SkDebuggerGUI.h b/debugger/QT/SkDebuggerGUI.h
index 6f6f647..5c003b0 100644
--- a/debugger/QT/SkDebuggerGUI.h
+++ b/debugger/QT/SkDebuggerGUI.h
@@ -304,10 +304,6 @@
QMenu fMenuView;
QMenu fMenuWindows;
- bool fBreakpointsActivated;
- bool fIndexStyleToggle;
- bool fDeletesActivated;
- bool fPause;
bool fLoading;
int fPausedRow;
@@ -354,6 +350,10 @@
void run(const SkPicture* pict,
sk_tools::PictureRenderer* renderer,
int repeats);
+
+ bool isPaused() const {
+ return fActionPause.isChecked();
+ }
};
#endif // SKDEBUGGERUI_H