From 158b515e21f0f0154041cd5985ec38fe37c0e875 Mon Sep 17 00:00:00 2001 From: rathnor Date: Thu, 2 Oct 2003 16:14:41 +0000 Subject: address some memory issues shown up with valgrind --- ChangeLog | 4 ++++ src/FbTk/EventManager.cc | 21 ++++++++++----------- src/FbTk/TextureRender.cc | 8 ++++---- src/Gnome.cc | 4 ++-- src/Screen.cc | 7 +++++-- src/WinClient.cc | 5 +++-- src/Window.cc | 7 ++++++- src/Xutil.cc | 6 +++++- src/main.cc | 4 ++-- 9 files changed, 41 insertions(+), 25 deletions(-) diff --git a/ChangeLog b/ChangeLog index cacb377..62647f4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,10 @@ (Format: Year/Month/Day) Changes for 0.9.6: *03/10/02: + * Fix couple of memory leaks and uninitialised uses shown up with + valgrind (Simon) + EventManager.cc TextureRender.cc Gnome.cc Screen.cc Window.cc + WinClient.cc Xutil.cc main.cc * Make grips children of handle (Simon) - Fixes parentrelative grip texture FbWinFrame.hh/cc diff --git a/src/FbTk/EventManager.cc b/src/FbTk/EventManager.cc index eadc701..ff01794 100644 --- a/src/FbTk/EventManager.cc +++ b/src/FbTk/EventManager.cc @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: EventManager.cc,v 1.8 2003/08/27 00:21:54 fluxgen Exp $ +// $Id: EventManager.cc,v 1.9 2003/10/02 16:14:41 rathnor Exp $ #include "EventManager.hh" #include "FbWindow.hh" @@ -114,19 +114,18 @@ void EventManager::dispatch(Window win, XEvent &ev, bool parent) { Window root, parent_win, *children = 0; unsigned int num_children; if (XQueryTree(FbTk::App::instance()->display(), win, - &root, &parent_win, &children, &num_children) != 0 && - parent_win != 0 && - parent_win != root) { - - if (children != 0) + &root, &parent_win, &children, &num_children) != 0) { + if (children != 0) XFree(children); - if (m_parent[parent_win] == 0) - return; - - // dispatch event to parent - dispatch(parent_win, ev, true); + if (parent_win != 0 && + parent_win != root) { + if (m_parent[parent_win] == 0) + return; + // dispatch event to parent + dispatch(parent_win, ev, true); + } } } diff --git a/src/FbTk/TextureRender.cc b/src/FbTk/TextureRender.cc index 40a7e72..f1f1103 100644 --- a/src/FbTk/TextureRender.cc +++ b/src/FbTk/TextureRender.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: TextureRender.cc,v 1.4 2003/08/12 11:44:41 fluxgen Exp $ +// $Id: TextureRender.cc,v 1.5 2003/10/02 16:14:41 rathnor Exp $ #include "TextureRender.hh" @@ -57,7 +57,7 @@ TextureRender::TextureRender(ImageControl &imgctrl, height = 3200; } - red = new (nothrow) unsigned char[width * height]; + red = new unsigned char[width * height]; if (red == 0) { char sbuf[128]; sprintf(sbuf, "%d", width*height); @@ -65,14 +65,14 @@ TextureRender::TextureRender(ImageControl &imgctrl, } - green = new (nothrow) unsigned char[width * height]; + green = new unsigned char[width * height]; if (green == 0) { char sbuf[128]; sprintf(sbuf, "%d", width*height); throw string("TextureRender::TextureRender(): Out of memory while allocating green buffer. size " + string(sbuf)); } - blue = new (nothrow) unsigned char[width * height]; + blue = new unsigned char[width * height]; if (blue == 0) { char sbuf[128]; sprintf(sbuf, "%d", width*height); diff --git a/src/Gnome.cc b/src/Gnome.cc index 2059839..86f7f75 100644 --- a/src/Gnome.cc +++ b/src/Gnome.cc @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Gnome.cc,v 1.31 2003/07/28 15:06:33 rathnor Exp $ +// $Id: Gnome.cc,v 1.32 2003/10/02 16:14:41 rathnor Exp $ #include "Gnome.hh" @@ -147,7 +147,7 @@ void Gnome::updateClientList(BScreen &screen) { num += (*win_it)->numClients(); } - Window *wl = new (nothrow) Window[num]; + Window *wl = new Window[num]; if (wl == 0) { cerr<<"Fatal: Out of memory, can't allocate ("<getFocusedWindow(); focused_list.remove(&client); if (cyc == &client) { diff --git a/src/WinClient.cc b/src/WinClient.cc index e032304..dadabe3 100644 --- a/src/WinClient.cc +++ b/src/WinClient.cc @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: WinClient.cc,v 1.28 2003/09/29 14:58:15 rathnor Exp $ +// $Id: WinClient.cc,v 1.29 2003/10/02 16:14:41 rathnor Exp $ #include "WinClient.hh" @@ -61,7 +61,8 @@ WinClient::WinClient(Window win, BScreen &screen, FluxboxWindow *fbwin):FbTk::Fb m_blackbox_hint(0), m_mwm_hint(0), m_focus_mode(F_PASSIVE), - m_diesig(*this), m_screen(screen) { + m_diesig(*this), m_screen(screen), + m_strut(0) { updateBlackboxHints(); updateMWMHints(); updateWMHints(); diff --git a/src/Window.cc b/src/Window.cc index 8609861..47fe00c 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Window.cc,v 1.237 2003/09/29 15:00:06 rathnor Exp $ +// $Id: Window.cc,v 1.238 2003/10/02 16:14:41 rathnor Exp $ #include "Window.hh" @@ -1126,6 +1126,11 @@ void FluxboxWindow::moveResize(int new_x, int new_y, } shape(); + + if (!moving) { + m_last_resize_x = new_x; + m_last_resize_y = new_y; + } } // returns whether the focus was "set" to this window diff --git a/src/Xutil.cc b/src/Xutil.cc index 5203469..671c52e 100644 --- a/src/Xutil.cc +++ b/src/Xutil.cc @@ -20,7 +20,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Xutil.cc,v 1.1 2003/06/22 12:23:57 fluxgen Exp $ +// $Id: Xutil.cc,v 1.2 2003/10/02 16:14:41 rathnor Exp $ #include "Xutil.hh" @@ -41,6 +41,7 @@ std::string getWMName(Window window) { Display *display = FbTk::App::instance()->display(); XTextProperty text_prop; + text_prop.value = 0; char **list; int num; I18n *i18n = I18n::instance(); @@ -62,6 +63,9 @@ std::string getWMName(Window window) { } else name = text_prop.value ? (char *)text_prop.value : ""; + + XFree(text_prop.value); + } else { // default name name = i18n->getMessage(FBNLS::WindowSet, FBNLS::WindowUnnamed, "Unnamed"); diff --git a/src/main.cc b/src/main.cc index c3bc73a..9a91e35 100644 --- a/src/main.cc +++ b/src/main.cc @@ -20,7 +20,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: main.cc,v 1.23 2003/08/28 23:18:37 fluxgen Exp $ +// $Id: main.cc,v 1.24 2003/10/02 16:14:41 rathnor Exp $ #include "fluxbox.hh" #include "I18n.hh" @@ -135,7 +135,7 @@ void showInfo(ostream &ostr) { int main(int argc, char **argv) { - std::string session_display; + std::string session_display = ""; std::string rc_file; std::string log_filename; -- cgit v0.11.2