Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1512)

Unified Diff: debugger/QT/SkDebuggerGUI.cpp

Issue 821663003: Change DebugCanvas API to not encourage memory leaks (Closed) Base URL: https://skia.googlesource.com/skia.git@debugger-raster-black-bg
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: debugger/QT/SkDebuggerGUI.cpp
diff --git a/debugger/QT/SkDebuggerGUI.cpp b/debugger/QT/SkDebuggerGUI.cpp
index 949137fc286714183a2c972733a0caead9b9566b..e54f5e6d886020366c773ca565257c0b355a5949 100644
--- a/debugger/QT/SkDebuggerGUI.cpp
+++ b/debugger/QT/SkDebuggerGUI.cpp
@@ -774,9 +774,11 @@ void SkDebuggerGUI::loadPicture(const SkString& fileName) {
SkSafeUnref(picture);
// Will this automatically clear out due to nature of refcnt?
- SkTArray<SkString>* commands = fDebugger.getDrawCommandsAsStrings();
- SkTDArray<size_t>* offsets = fDebugger.getDrawCommandOffsets();
- SkASSERT(commands->count() == offsets->count());
+ SkTArray<SkString> commands;
+ fDebugger.getDrawCommandsAsStrings(&commands);
+ SkTDArray<size_t> offsets;
+ fDebugger.getDrawCommandOffsets(&offsets);
+ SkASSERT(commands.count() == offsets.count());
fActionProfile.setDisabled(false);
@@ -801,31 +803,31 @@ void SkDebuggerGUI::loadPicture(const SkString& fileName) {
actionPlay();
}
-void SkDebuggerGUI::setupListWidget(SkTArray<SkString>* commands, SkTDArray<size_t>* offsets) {
- SkASSERT(commands->count() == offsets->count());
+void SkDebuggerGUI::setupListWidget(const SkTArray<SkString>& commands, const SkTDArray<size_t>& offsets) {
+ SkASSERT(commands.count() == offsets.count());
fListWidget.clear();
int counter = 0;
int indent = 0;
- for (int i = 0; i < commands->count(); i++) {
+ for (int i = 0; i < commands.count(); i++) {
QListWidgetItem *item = new QListWidgetItem();
- item->setData(Qt::DisplayRole, (*commands)[i].c_str());
+ item->setData(Qt::DisplayRole, commands[i].c_str());
item->setData(Qt::UserRole + 1, counter++);
- if (0 == strcmp("Restore", (*commands)[i].c_str()) ||
- 0 == strcmp("EndCommentGroup", (*commands)[i].c_str())) {
+ if (0 == strcmp("Restore", commands[i].c_str()) ||
+ 0 == strcmp("EndCommentGroup", commands[i].c_str())) {
indent -= 10;
}
item->setData(Qt::UserRole + 3, indent);
- if (0 == strcmp("Save", (*commands)[i].c_str()) ||
- 0 == strcmp("Save Layer", (*commands)[i].c_str()) ||
- 0 == strcmp("BeginCommentGroup", (*commands)[i].c_str())) {
+ if (0 == strcmp("Save", commands[i].c_str()) ||
+ 0 == strcmp("Save Layer", commands[i].c_str()) ||
+ 0 == strcmp("BeginCommentGroup", commands[i].c_str())) {
indent += 10;
}
item->setData(Qt::UserRole + 4, -1);
- item->setData(Qt::UserRole + 5, (int)(*offsets)[i]);
+ item->setData(Qt::UserRole + 5, (int)offsets[i]);
fListWidget.addItem(item);
}
@@ -845,13 +847,13 @@ void SkDebuggerGUI::setupClipStackText() {
fInspectorWidget.setText(clipStack.c_str(), SkInspectorWidget::kClipStack_TabType);
}
-void SkDebuggerGUI::setupComboBox(SkTArray<SkString>* command) {
+void SkDebuggerGUI::setupComboBox(const SkTArray<SkString>& command) {
fFilter.clear();
fFilter.addItem("--Filter By Available Commands--");
std::map<std::string, int> map;
- for (int i = 0; i < command->count(); i++) {
- map[(*command)[i].c_str()]++;
+ for (int i = 0; i < command.count(); i++) {
+ map[command[i].c_str()]++;
}
for (std::map<std::string, int>::iterator it = map.begin(); it != map.end();

Powered by Google App Engine
This is Rietveld 408576698