From cb0ad2786d4fe1ae7a1e2e4bd9892f6de359d065 Mon Sep 17 00:00:00 2001 From: Don Ho Date: Wed, 12 Aug 2015 22:35:15 +0200 Subject: [PATCH] [ENHANCEMENT] Remove incorrect assert statement 1. Remove incorrect assert statement. 2. Use standard allocation method instead of Microsoft's obscure one. --- PowerEditor/src/WinControls/StatusBar/StatusBar.cpp | 12 ++++-------- PowerEditor/src/WinControls/StatusBar/StatusBar.h | 3 +-- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/PowerEditor/src/WinControls/StatusBar/StatusBar.cpp b/PowerEditor/src/WinControls/StatusBar/StatusBar.cpp index 4f6c63b7..904d1b41 100644 --- a/PowerEditor/src/WinControls/StatusBar/StatusBar.cpp +++ b/PowerEditor/src/WinControls/StatusBar/StatusBar.cpp @@ -46,11 +46,8 @@ enum StatusBar::~StatusBar() { - if (NULL != _hloc) - { - ::LocalUnlock(_hloc); - ::LocalFree(_hloc); - } + if (_lpParts != nullptr) + delete[] _lpParts; } @@ -62,7 +59,6 @@ void StatusBar::init(HINSTANCE /*hInst*/, HWND /*hPere*/) void StatusBar::init(HINSTANCE hInst, HWND hPere, int nbParts) { - assert(nbParts > 0); Window::init(hInst, hPere); InitCommonControls(); @@ -84,8 +80,8 @@ void StatusBar::init(HINSTANCE hInst, HWND hPere, int nbParts) _partWidthArray.resize(nbParts, (int) defaultPartWidth); // Allocate an array for holding the right edge coordinates. - _hloc = ::LocalAlloc(LHND, sizeof(int) * _partWidthArray.size()); - _lpParts = (LPINT)::LocalLock(_hloc); + if (_partWidthArray.size()) + _lpParts = new int[_partWidthArray.size()]; RECT rc; ::GetClientRect(_hParent, &rc); diff --git a/PowerEditor/src/WinControls/StatusBar/StatusBar.h b/PowerEditor/src/WinControls/StatusBar/StatusBar.h index 120bc493..cadad037 100644 --- a/PowerEditor/src/WinControls/StatusBar/StatusBar.h +++ b/PowerEditor/src/WinControls/StatusBar/StatusBar.h @@ -60,7 +60,6 @@ private: private: std::vector _partWidthArray; - HLOCAL _hloc = NULL; - LPINT _lpParts = NULL; + int *_lpParts = nullptr; generic_string _lastSetText; }; \ No newline at end of file