Fixed numerous mem errors

Review URL: https://codereview.appspot.com/6441070

git-svn-id: http://skia.googlecode.com/svn/trunk@4849 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
chudy@google.com 2012-07-31 12:49:52 +00:00
parent f8d904a7ee
commit 2d537a18f4
11 changed files with 43 additions and 50 deletions

View 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()) {

View 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,

View 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);

View 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.

View 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() {

View 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);
};

View 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);
}

View 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);

View 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) {

View 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));

View 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_ */