From: chudy@google.com Date: Tue, 31 Jul 2012 12:49:52 +0000 (+0000) Subject: Fixed numerous mem errors X-Git-Tag: accepted/tizen/5.0/unified/20181102.025319~15372 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2d537a18f49cb492358c2b051f4786075dd9406c;p=platform%2Fupstream%2FlibSkiaSharp.git 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 --- diff --git a/debugger/QT/SkCanvasWidget.cpp b/debugger/QT/SkCanvasWidget.cpp index 47db709..e4716af 100644 --- a/debugger/QT/SkCanvasWidget.cpp +++ b/debugger/QT/SkCanvasWidget.cpp @@ -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()) { diff --git a/debugger/QT/SkCanvasWidget.h b/debugger/QT/SkCanvasWidget.h index a73ffc8..317a007 100644 --- a/debugger/QT/SkCanvasWidget.h +++ b/debugger/QT/SkCanvasWidget.h @@ -20,9 +20,9 @@ class SkCanvasWidget : public QWidget { Q_OBJECT public: - SkCanvasWidget(QWidget* parent); + SkCanvasWidget(); - ~SkCanvasWidget() {} + ~SkCanvasWidget(); enum WidgetType { kRaster_8888_WidgetType = 1 << 0, diff --git a/debugger/QT/SkDebuggerGUI.cpp b/debugger/QT/SkDebuggerGUI.cpp index e497ff7..25f2ba9 100644 --- a/debugger/QT/SkDebuggerGUI.cpp +++ b/debugger/QT/SkDebuggerGUI.cpp @@ -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); diff --git a/debugger/QT/SkDebuggerGUI.h b/debugger/QT/SkDebuggerGUI.h index 3e4d319..d8b5c74 100644 --- a/debugger/QT/SkDebuggerGUI.h +++ b/debugger/QT/SkDebuggerGUI.h @@ -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. diff --git a/debugger/QT/SkGLWidget.cpp b/debugger/QT/SkGLWidget.cpp index 395cf44..74ed48e 100644 --- a/debugger/QT/SkGLWidget.cpp +++ b/debugger/QT/SkGLWidget.cpp @@ -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() { diff --git a/debugger/QT/SkGLWidget.h b/debugger/QT/SkGLWidget.h index 4a036aa..5295f4c 100644 --- a/debugger/QT/SkGLWidget.h +++ b/debugger/QT/SkGLWidget.h @@ -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); }; diff --git a/debugger/QT/SkInspectorWidget.cpp b/debugger/QT/SkInspectorWidget.cpp index 3f64e6f..e09c25b 100644 --- a/debugger/QT/SkInspectorWidget.cpp +++ b/debugger/QT/SkInspectorWidget.cpp @@ -10,8 +10,7 @@ #include "SkInspectorWidget.h" #include -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); } diff --git a/debugger/QT/SkInspectorWidget.h b/debugger/QT/SkInspectorWidget.h index 3e76104..78a8344 100644 --- a/debugger/QT/SkInspectorWidget.h +++ b/debugger/QT/SkInspectorWidget.h @@ -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); diff --git a/debugger/QT/SkRasterWidget.cpp b/debugger/QT/SkRasterWidget.cpp index 8c6a284..db89de7 100644 --- a/debugger/QT/SkRasterWidget.cpp +++ b/debugger/QT/SkRasterWidget.cpp @@ -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) { diff --git a/debugger/QT/SkSettingsWidget.cpp b/debugger/QT/SkSettingsWidget.cpp index bc37a12..2519efd 100644 --- a/debugger/QT/SkSettingsWidget.cpp +++ b/debugger/QT/SkSettingsWidget.cpp @@ -12,7 +12,7 @@ #include // 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)); diff --git a/debugger/QT/SkSettingsWidget.h b/debugger/QT/SkSettingsWidget.h index 1afb93e..fdb99d1 100644 --- a/debugger/QT/SkSettingsWidget.h +++ b/debugger/QT/SkSettingsWidget.h @@ -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_ */