address some memory issues shown up with valgrind

This commit is contained in:
rathnor 2003-10-02 16:14:41 +00:00
parent bb1a7c92d8
commit 158b515e21
9 changed files with 41 additions and 25 deletions

View file

@ -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

View file

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

View file

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

View file

@ -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 ("<<num*sizeof (Window)<<") for gnome client list"<<endl;
return;

View file

@ -22,7 +22,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
// $Id: Screen.cc,v 1.235 2003/09/29 12:53:58 rathnor Exp $
// $Id: Screen.cc,v 1.236 2003/10/02 16:14:41 rathnor Exp $
#include "Screen.hh"
@ -731,7 +731,10 @@ void BScreen::removeWindow(FluxboxWindow *win) {
void BScreen::removeClient(WinClient &client) {
WinClient *cyc = *cycling_window;
WinClient *cyc = 0;
if (cycling_window != focused_list.end())
cyc = *cycling_window;
WinClient *focused = Fluxbox::instance()->getFocusedWindow();
focused_list.remove(&client);
if (cyc == &client) {

View file

@ -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();

View file

@ -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

View file

@ -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");

View file

@ -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;