From 7574fe4c266832849ca326b0d4b8bbfd35873544 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 5 Jul 2014 03:13:01 +0200 Subject: [PATCH] No need to store the loaded image data after passing it to the label. --- .../studio/src/plugins/gui_editor/texture_chooser.cpp | 11 ++++------- code/studio/src/plugins/gui_editor/texture_chooser.h | 2 -- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/code/studio/src/plugins/gui_editor/texture_chooser.cpp b/code/studio/src/plugins/gui_editor/texture_chooser.cpp index 11e5a30fd..04328d9ef 100644 --- a/code/studio/src/plugins/gui_editor/texture_chooser.cpp +++ b/code/studio/src/plugins/gui_editor/texture_chooser.cpp @@ -12,13 +12,10 @@ QDialog( parent ) { setupUi( this ); setupConnections(); - data = NULL; } TextureChooser::~TextureChooser() { - delete data; - data = NULL; } @@ -61,10 +58,7 @@ void TextureChooser::onCurrentRowChanged( int row ) uint32 size = bm.getSize() * ( 32 / 8 ); // should be depth, but CBitmap always uses 32 bit to store the image - if( data != NULL ) - delete data; - - data = new uint8[ size ]; + uint8 *data = new uint8[ size ]; bm.getData( data ); /// Convert from ABGR to ARGB @@ -86,6 +80,9 @@ void TextureChooser::onCurrentRowChanged( int row ) QImage img( data, bm.getWidth(), bm.getHeight(), QImage::Format_ARGB32 ); label->setPixmap( QPixmap::fromImage( img ) ); + delete data; + data = NULL; + } diff --git a/code/studio/src/plugins/gui_editor/texture_chooser.h b/code/studio/src/plugins/gui_editor/texture_chooser.h index fecd0aa1e..24b93fc40 100644 --- a/code/studio/src/plugins/gui_editor/texture_chooser.h +++ b/code/studio/src/plugins/gui_editor/texture_chooser.h @@ -18,8 +18,6 @@ private Q_SLOTS: private: void setupConnections(); - - unsigned char *data; }; #endif