Fixed numerous mem errors
authorchudy@google.com <chudy@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Tue, 31 Jul 2012 12:49:52 +0000 (12:49 +0000)
committerchudy@google.com <chudy@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Tue, 31 Jul 2012 12:49:52 +0000 (12:49 +0000)
Review URL: https://codereview.appspot.com/6441070

git-svn-id: http://skia.googlecode.com/svn/trunk@4849 2bbb7eff-a529-9590-31e7-b0007b416f81

debugger/QT/SkCanvasWidget.cpp
debugger/QT/SkCanvasWidget.h
debugger/QT/SkDebuggerGUI.cpp
debugger/QT/SkDebuggerGUI.h
debugger/QT/SkGLWidget.cpp
debugger/QT/SkGLWidget.h
debugger/QT/SkInspectorWidget.cpp
debugger/QT/SkInspectorWidget.h
debugger/QT/SkRasterWidget.cpp
debugger/QT/SkSettingsWidget.cpp
debugger/QT/SkSettingsWidget.h

index 47db709..e4716af 100644 (file)
@@ -9,10 +9,8 @@
 
 #include "SkCanvasWidget.h"
 
-SkCanvasWidget::SkCanvasWidget(QWidget* parent) : QWidget(parent)
+SkCanvasWidget::SkCanvasWidget() : QWidget()
     , fHorizontalLayout(this)
-    , fRasterWidget(this)
-    , fGLWidget(this)
 {
     fHorizontalLayout.setSpacing(6);
     fHorizontalLayout.setContentsMargins(0,0,0,0);
@@ -34,6 +32,12 @@ SkCanvasWidget::SkCanvasWidget(QWidget* parent) : QWidget(parent)
     this->setDisabled(true);
 }
 
+SkCanvasWidget::~SkCanvasWidget() {
+    if (fDebugCanvas) {
+        delete fDebugCanvas;
+    }
+}
+
 void SkCanvasWidget::drawTo(int index) {
     fIndex = index;
     if (!fRasterWidget.isHidden()) {
index a73ffc8..317a007 100644 (file)
@@ -20,9 +20,9 @@ class SkCanvasWidget : public QWidget {
     Q_OBJECT
 
 public:
-    SkCanvasWidget(QWidget* parent);
+    SkCanvasWidget();
 
-    ~SkCanvasWidget() {}
+    ~SkCanvasWidget();
 
     enum WidgetType {
         kRaster_8888_WidgetType = 1 << 0,
index e497ff7..25f2ba9 100644 (file)
@@ -11,6 +11,9 @@
 
 SkDebuggerGUI::SkDebuggerGUI(QWidget *parent) :
         QMainWindow(parent)
+    , fCentralWidget(this)
+    , fStatusBar(this)
+    , fToolBar(this)
     , fActionOpen(this)
     , fActionBreakpoint(this)
     , fActionCancel(this)
@@ -33,19 +36,12 @@ SkDebuggerGUI::SkDebuggerGUI(QWidget *parent) :
     , fActionZoomIn(this)
     , fActionZoomOut(this)
     , fMapper(this)
-    , fCentralWidget(this)
-    , fFilter(&fCentralWidget)
-    , fContainerLayout(&fCentralWidget)
     , fListWidget(&fCentralWidget)
     , fDirectoryWidget(&fCentralWidget)
-    , fCanvasWidget(&fCentralWidget)
-    , fSettingsWidget(&fCentralWidget)
-    , fStatusBar(this)
     , fMenuBar(this)
     , fMenuFile(this)
     , fMenuNavigate(this)
     , fMenuView(this)
-    , fToolBar(this)
     , fBreakpointsActivated(false)
     , fDeletesActivated(false)
     , fPause(false)
@@ -94,11 +90,9 @@ SkDebuggerGUI::SkDebuggerGUI(QWidget *parent) :
     fMenuEdit.setDisabled(true);
     fMenuNavigate.setDisabled(true);
     fMenuView.setDisabled(true);
-
 }
 
-SkDebuggerGUI::~SkDebuggerGUI() {
-}
+SkDebuggerGUI::~SkDebuggerGUI() {}
 
 void SkDebuggerGUI::actionBreakpoints() {
     fBreakpointsActivated = !fBreakpointsActivated;
@@ -497,6 +491,7 @@ void SkDebuggerGUI::setupUi(QMainWindow *SkDebuggerGUI) {
     fMainAndRightColumnLayout.addLayout(&fCanvasAndSettingsLayout);
     fMainAndRightColumnLayout.addWidget(&fInspectorWidget);
 
+    fCentralWidget.setLayout(&fContainerLayout);
     fContainerLayout.setSpacing(6);
     fContainerLayout.setContentsMargins(11, 11, 11, 11);
     fContainerLayout.addLayout(&fLeftColumnLayout);
index 3e4d319..d8b5c74 100644 (file)
@@ -195,6 +195,10 @@ private slots:
     void toggleFilter(QString string);
 
 private:
+    QWidget fCentralWidget;
+    QStatusBar fStatusBar;
+    QToolBar fToolBar;
+
     QAction fActionOpen;
     QAction fActionBreakpoint;
     QAction fActionCancel;
@@ -217,13 +221,13 @@ private:
     QAction fActionZoomIn;
     QAction fActionZoomOut;
     QSignalMapper fMapper;
-    QWidget fCentralWidget;
+
     QWidget fSpacer;
     QComboBox fFilter;
 
+    QHBoxLayout fContainerLayout;
     QVBoxLayout fLeftColumnLayout;
     QVBoxLayout fMainAndRightColumnLayout;
-    QHBoxLayout fContainerLayout;
     QHBoxLayout fCanvasAndSettingsLayout;
 
     QListWidget fListWidget;
@@ -232,7 +236,6 @@ private:
     SkCanvasWidget fCanvasWidget;
     SkInspectorWidget fInspectorWidget;
     SkSettingsWidget fSettingsWidget;
-    QStatusBar fStatusBar;
 
     QString fPath;
     bool fDirectoryWidgetActive;
@@ -243,13 +246,12 @@ private:
     QMenu fMenuNavigate;
     QMenu fMenuView;
     QMenu fMenuWindows;
-    QToolBar fToolBar;
 
     bool fBreakpointsActivated;
     bool fDeletesActivated;
     bool fPause;
-    int fPausedRow;
     bool fLoading;
+    int fPausedRow;
 
     /**
         Creates the entire UI.
index 395cf44..74ed48e 100644 (file)
@@ -9,12 +9,15 @@
 
 #include "SkGLWidget.h"
 
-SkGLWidget::SkGLWidget(QWidget* parent) : QGLWidget(parent) {
+SkGLWidget::SkGLWidget() : QGLWidget() {
     this->setStyleSheet("QWidget {background-color: white; border: 1px solid #cccccc;}");
     fTransform.set(0,0);
     fScaleFactor = 1.0;
     fIndex = 0;
     fDebugCanvas = NULL;
+    fCurIntf = NULL;
+    fCurContext = NULL;
+    fGpuDevice = NULL;
 }
 
 SkGLWidget::~SkGLWidget() {
index 4a036aa..5295f4c 100644 (file)
@@ -23,7 +23,7 @@
 class SkGLWidget : public QGLWidget {
 
 public:
-    SkGLWidget(QWidget* parent = NULL);
+    SkGLWidget();
 
     ~SkGLWidget();
 
@@ -61,7 +61,6 @@ private:
     int fIndex;
     SkIPoint fTransform;
     float fScaleFactor;
-
     GrPlatformRenderTargetDesc getDesc(int w, int h);
 };
 
index 3f64e6f..e09c25b 100644 (file)
@@ -10,8 +10,7 @@
 #include "SkInspectorWidget.h"
 #include <iostream>
 
-SkInspectorWidget::SkInspectorWidget(QWidget *parent)
-    : QWidget(parent)
+SkInspectorWidget::SkInspectorWidget() : QWidget()
     , fHorizontalLayout(this)
     , fOverviewTab()
     , fOverviewLayout(&fOverviewTab)
@@ -59,8 +58,6 @@ SkInspectorWidget::SkInspectorWidget(QWidget *parent)
     fHorizontalLayout.addWidget(&fMatrixAndClipWidget);
 }
 
-SkInspectorWidget::~SkInspectorWidget() {}
-
 void SkInspectorWidget::setDetailText(QString text) {
     fDetailText.setHtml(text);
 }
index 3e76104..78a8344 100644 (file)
@@ -32,9 +32,7 @@ public:
         Constructs a widget with the specified parent for layout purposes.
         @param parent  The parent container of this widget
      */
-    SkInspectorWidget(QWidget *parent = NULL);
-
-    ~SkInspectorWidget();
+    SkInspectorWidget();
 
     void setDisabled(bool isDisabled) {
         fMatrixAndClipWidget.setDisabled(isDisabled);
index 8c6a284..db89de7 100644 (file)
@@ -16,26 +16,25 @@ SkRasterWidget::SkRasterWidget(QWidget* parent) : QWidget(parent) {
     fTransform.set(0,0);
     fScaleFactor = 1.0;
     fIndex = 0;
+    fDevice = NULL;
     fDebugCanvas = NULL;
     this->setStyleSheet("QWidget {background-color: white; border: 1px solid #cccccc;}");
 }
 
 SkRasterWidget::~SkRasterWidget() {
     delete fDevice;
-    delete fDebugCanvas;
 }
 
 void SkRasterWidget::resizeEvent(QResizeEvent* event) {
     fBitmap.setConfig(SkBitmap::kARGB_8888_Config, event->size().width(), event->size().height());
     fBitmap.allocPixels();
-    delete fDevice;
-    fDevice = new SkDevice(fBitmap);
-    //TODO(chudy): Debug Canvas shouldn't store current size. The bitmap
-    //or texture backend should already have it. Refactor.
-    if (fDebugCanvas) {
-        fDebugCanvas->setBounds(event->size().width(), event->size().height());
-        this->update();
+    if (fDevice) {
+        delete fDevice;
     }
+        fDevice = new SkDevice(fBitmap);
+
+
+    this->update();
 }
 
 void SkRasterWidget::paintEvent(QPaintEvent* event) {
index bc37a12..2519efd 100644 (file)
@@ -12,7 +12,7 @@
 #include <math.h>
 
 // TODO(chudy): See if the layout can't be attached to the frame post construction.
-SkSettingsWidget::SkSettingsWidget(QWidget *parent) : QWidget(parent)
+SkSettingsWidget::SkSettingsWidget() : QWidget()
     , mainFrameLayout(this)
     , fVerticalLayout(&mainFrame)
     , fVisibleFrameLayout(&fVisibleFrame)
@@ -22,8 +22,8 @@ SkSettingsWidget::SkSettingsWidget(QWidget *parent) : QWidget(parent)
     , fCurrentCommandBox(&fCommandFrame)
     , fCommandHitBox(&fCommandFrame)
     , fCanvasLayout(&fCanvasFrame)
-    , fZoomBox(&fZoomFrame)
     , fZoomLayout(&fZoomFrame)
+    , fZoomBox(&fZoomFrame)
 {
     // Sets up the container and it's alignment around the settings widget.
     mainFrame.setFrameShape(QFrame::StyledPanel);
@@ -71,7 +71,6 @@ SkSettingsWidget::SkSettingsWidget(QWidget *parent) : QWidget(parent)
 
     fCanvasLayout.setSpacing(6);
     fCanvasLayout.setContentsMargins(11,11,11,11);
-    fCanvasLayout.addWidget(&fCanvasToggle);
     fCanvasLayout.addLayout(&fRasterLayout);
     fCanvasLayout.addLayout(&fGLLayout);
 
@@ -139,8 +138,6 @@ SkSettingsWidget::SkSettingsWidget(QWidget *parent) : QWidget(parent)
     this->setDisabled(true);
 }
 
-SkSettingsWidget::~SkSettingsWidget() {}
-
 
 void SkSettingsWidget::updateCommand(int newCommand) {
     fCurrentCommandBox.setText(QString::number(newCommand));
index 1afb93e..fdb99d1 100644 (file)
@@ -32,8 +32,7 @@ public:
         Constructs a widget with the specified parent for layout purposes.
         @param parent  The parent container of this widget
      */
-    SkSettingsWidget(QWidget *parent = NULL);
-    ~SkSettingsWidget();
+    SkSettingsWidget();
 
     void setZoomText(int scaleFactor);
 
@@ -71,17 +70,17 @@ private:
     QFrame fCommandFrame;
     QVBoxLayout fCommandLayout;
 
+    QHBoxLayout fCurrentCommandLayout;
     QLabel fCurrentCommandLabel;
     QLineEdit fCurrentCommandBox;
-    QHBoxLayout fCurrentCommandLayout;
 
+    QHBoxLayout fCommandHitLayout;
     QLabel fCommandHitLabel;
     QLineEdit fCommandHitBox;
-    QHBoxLayout fCommandHitLayout;
 
-    QLabel fCanvasToggle;
     QFrame fCanvasFrame;
     QVBoxLayout fCanvasLayout;
+    QLabel fCanvasToggle;
 
     QHBoxLayout fRasterLayout;
     QLabel fRasterLabel;
@@ -91,10 +90,10 @@ private:
     QLabel fGLLabel;
     QCheckBox fGLCheckBox;
 
-    QLabel fZoomSetting;
     QFrame fZoomFrame;
-    QLineEdit fZoomBox;
     QHBoxLayout fZoomLayout;
+    QLabel fZoomSetting;
+    QLineEdit fZoomBox;
 };
 
 #endif /* SKSETTINGSWIDGET_H_ */