From 3e61c765b5ca868fcd94b3e91e36f595666e52c9 Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Thu, 28 Jan 1999 09:57:29 +0000 Subject: [PATCH] Found mem leaks (except one) Next take at focus vs. keyboard input probs git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1503 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/gtk/app.cpp | 12 ++++++------ src/gtk/utilsres.cpp | 37 +++++++++++++++++++++++++------------ src/gtk/window.cpp | 13 +++++++++++-- src/gtk1/app.cpp | 12 ++++++------ src/gtk1/utilsres.cpp | 37 +++++++++++++++++++++++++------------ src/gtk1/window.cpp | 13 +++++++++++-- 6 files changed, 84 insertions(+), 40 deletions(-) diff --git a/src/gtk/app.cpp b/src/gtk/app.cpp index 418183b6e4..78511d556f 100644 --- a/src/gtk/app.cpp +++ b/src/gtk/app.cpp @@ -451,6 +451,12 @@ void wxApp::CleanUp(void) delete wxTheApp; wxTheApp = (wxApp*) NULL; + wxSystemSettings::Done(); + + delete[] wxBuffer; + + wxClassInfo::CleanUpClasses(); + /* check for memory leaks */ #if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT if (wxDebugContext::CountObjectsLeft() > 0) @@ -466,12 +472,6 @@ void wxApp::CleanUp(void) wxLog *oldLog = wxLog::SetActiveTarget( (wxLog*) NULL ); if (oldLog) delete oldLog; - - wxSystemSettings::Done(); - - wxClassInfo::CleanUpClasses(); - - delete[] wxBuffer; } wxLog *wxApp::CreateLogTarget() diff --git a/src/gtk/utilsres.cpp b/src/gtk/utilsres.cpp index fe447a9b1a..52e3199178 100644 --- a/src/gtk/utilsres.cpp +++ b/src/gtk/utilsres.cpp @@ -57,19 +57,22 @@ extern XrmDatabase wxResourceDatabase; static char *GetResourcePath(char *buf, char *name, bool create) { - if (create && FileExists(name)) { + if (create && FileExists(name)) + { strcpy(buf, name); return buf; // Exists so ... } if (*name == '/') strcpy(buf, name); - else { + else + { // Put in standard place for resource files if not absolute strcpy(buf, DEFAULT_XRESOURCE_DIR); strcat(buf, "/"); strcat(buf, FileNameFromPath(name)); } - if (create) { + if (create) + { // Touch the file to create it FILE *fd = fopen(buf, "w"); if (fd) fclose(fd); @@ -129,9 +132,12 @@ static void wxXMergeDatabases() // window when the server initializes and loaded into the display // structure on XOpenDisplay; // if not defined, use .Xdefaults - if (XResourceManagerString(GDK_DISPLAY()) != NULL) { + if (XResourceManagerString(GDK_DISPLAY()) != NULL) + { serverDB = XrmGetStringDatabase(XResourceManagerString(GDK_DISPLAY())); - } else { + } + else + { (void)GetIniFile(filename, (char *) NULL); serverDB = XrmGetFileDatabase(filename); } @@ -141,7 +147,8 @@ static void wxXMergeDatabases() // Open XENVIRONMENT file, or if not defined, the .Xdefaults, // and merge into existing database - if ((environment = getenv("XENVIRONMENT")) == NULL) { + if ((environment = getenv("XENVIRONMENT")) == NULL) + { size_t len; environment = GetIniFile(filename, (const char *) NULL); len = strlen(environment); @@ -249,7 +256,8 @@ bool wxGetResource(const wxString& section, const wxString& entry, char **value, wxXMergeDatabases(); XrmDatabase database; - if ( !file.IsEmpty() ) { + if (!file.IsEmpty()) + { char buffer[500]; // Is this right? Trying to get it to look in the user's // home directory instead of current directory -- JACS @@ -279,11 +287,13 @@ bool wxGetResource(const wxString& section, const wxString& entry, char **value, bool success = XrmGetResource(database, buf, "*", str_type, &xvalue); // Try different combinations of upper/lower case, just in case... - if (!success) { + if (!success) + { buf[0] = (isupper(buf[0]) ? tolower(buf[0]) : toupper(buf[0])); success = XrmGetResource(database, buf, "*", str_type, &xvalue); } - if (success) { + if (success) + { if (*value) delete[] *value; *value = new char[xvalue.size + 1]; @@ -297,7 +307,8 @@ bool wxGetResource(const wxString& section, const wxString& entry, float *value, { char *s = (char *) NULL; bool succ = wxGetResource(section, entry, &s, file); - if (succ) { + if (succ) + { *value = (float)strtod(s, (char **) NULL); delete[]s; return TRUE; @@ -309,7 +320,8 @@ bool wxGetResource(const wxString& section, const wxString& entry, long *value, { char *s = (char *) NULL; bool succ = wxGetResource(section, entry, &s, file); - if (succ) { + if (succ) + { *value = strtol(s, (char **) NULL, 10); delete[]s; return TRUE; @@ -321,7 +333,8 @@ bool wxGetResource(const wxString& section, const wxString& entry, int *value, c { char *s = (char *) NULL; bool succ = wxGetResource(section, entry, &s, file); - if (succ) { + if (succ) + { // Handle True, False here // True, Yes, Enables, Set or Activated if (*s == 'T' || *s == 'Y' || *s == 'E' || *s == 'S' || *s == 'A') diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 3f46517907..9b1cb42717 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -1257,6 +1257,13 @@ static void wxInsertChildInWindow( wxWindow* parent, wxWindow* child ) { parent->m_sizeSet = FALSE; } + + if (parent->m_windowStyle & wxTAB_TRAVERSAL) + { + /* we now allow a window to get the focus as long as it + doesn't have any children. */ + GTK_WIDGET_UNSET_FLAGS( parent->m_wxwindow, GTK_CAN_FOCUS ); + } } //----------------------------------------------------------------------------- @@ -1421,9 +1428,11 @@ bool wxWindow::Create( wxWindow *parent, wxWindowID id, gtk_viewport_set_shadow_type( viewport, GTK_SHADOW_NONE ); } - if ((m_windowStyle & wxTAB_TRAVERSAL) != 0) + if (m_windowStyle & wxTAB_TRAVERSAL) { - GTK_WIDGET_SET_FLAGS( m_wxwindow, GTK_CAN_FOCUS ); /* changed from UNSET */ + /* we now allow a window to get the focus as long as it + doesn't have any children. */ + GTK_WIDGET_SET_FLAGS( m_wxwindow, GTK_CAN_FOCUS ); m_acceptsFocus = FALSE; } else diff --git a/src/gtk1/app.cpp b/src/gtk1/app.cpp index 418183b6e4..78511d556f 100644 --- a/src/gtk1/app.cpp +++ b/src/gtk1/app.cpp @@ -451,6 +451,12 @@ void wxApp::CleanUp(void) delete wxTheApp; wxTheApp = (wxApp*) NULL; + wxSystemSettings::Done(); + + delete[] wxBuffer; + + wxClassInfo::CleanUpClasses(); + /* check for memory leaks */ #if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT if (wxDebugContext::CountObjectsLeft() > 0) @@ -466,12 +472,6 @@ void wxApp::CleanUp(void) wxLog *oldLog = wxLog::SetActiveTarget( (wxLog*) NULL ); if (oldLog) delete oldLog; - - wxSystemSettings::Done(); - - wxClassInfo::CleanUpClasses(); - - delete[] wxBuffer; } wxLog *wxApp::CreateLogTarget() diff --git a/src/gtk1/utilsres.cpp b/src/gtk1/utilsres.cpp index fe447a9b1a..52e3199178 100644 --- a/src/gtk1/utilsres.cpp +++ b/src/gtk1/utilsres.cpp @@ -57,19 +57,22 @@ extern XrmDatabase wxResourceDatabase; static char *GetResourcePath(char *buf, char *name, bool create) { - if (create && FileExists(name)) { + if (create && FileExists(name)) + { strcpy(buf, name); return buf; // Exists so ... } if (*name == '/') strcpy(buf, name); - else { + else + { // Put in standard place for resource files if not absolute strcpy(buf, DEFAULT_XRESOURCE_DIR); strcat(buf, "/"); strcat(buf, FileNameFromPath(name)); } - if (create) { + if (create) + { // Touch the file to create it FILE *fd = fopen(buf, "w"); if (fd) fclose(fd); @@ -129,9 +132,12 @@ static void wxXMergeDatabases() // window when the server initializes and loaded into the display // structure on XOpenDisplay; // if not defined, use .Xdefaults - if (XResourceManagerString(GDK_DISPLAY()) != NULL) { + if (XResourceManagerString(GDK_DISPLAY()) != NULL) + { serverDB = XrmGetStringDatabase(XResourceManagerString(GDK_DISPLAY())); - } else { + } + else + { (void)GetIniFile(filename, (char *) NULL); serverDB = XrmGetFileDatabase(filename); } @@ -141,7 +147,8 @@ static void wxXMergeDatabases() // Open XENVIRONMENT file, or if not defined, the .Xdefaults, // and merge into existing database - if ((environment = getenv("XENVIRONMENT")) == NULL) { + if ((environment = getenv("XENVIRONMENT")) == NULL) + { size_t len; environment = GetIniFile(filename, (const char *) NULL); len = strlen(environment); @@ -249,7 +256,8 @@ bool wxGetResource(const wxString& section, const wxString& entry, char **value, wxXMergeDatabases(); XrmDatabase database; - if ( !file.IsEmpty() ) { + if (!file.IsEmpty()) + { char buffer[500]; // Is this right? Trying to get it to look in the user's // home directory instead of current directory -- JACS @@ -279,11 +287,13 @@ bool wxGetResource(const wxString& section, const wxString& entry, char **value, bool success = XrmGetResource(database, buf, "*", str_type, &xvalue); // Try different combinations of upper/lower case, just in case... - if (!success) { + if (!success) + { buf[0] = (isupper(buf[0]) ? tolower(buf[0]) : toupper(buf[0])); success = XrmGetResource(database, buf, "*", str_type, &xvalue); } - if (success) { + if (success) + { if (*value) delete[] *value; *value = new char[xvalue.size + 1]; @@ -297,7 +307,8 @@ bool wxGetResource(const wxString& section, const wxString& entry, float *value, { char *s = (char *) NULL; bool succ = wxGetResource(section, entry, &s, file); - if (succ) { + if (succ) + { *value = (float)strtod(s, (char **) NULL); delete[]s; return TRUE; @@ -309,7 +320,8 @@ bool wxGetResource(const wxString& section, const wxString& entry, long *value, { char *s = (char *) NULL; bool succ = wxGetResource(section, entry, &s, file); - if (succ) { + if (succ) + { *value = strtol(s, (char **) NULL, 10); delete[]s; return TRUE; @@ -321,7 +333,8 @@ bool wxGetResource(const wxString& section, const wxString& entry, int *value, c { char *s = (char *) NULL; bool succ = wxGetResource(section, entry, &s, file); - if (succ) { + if (succ) + { // Handle True, False here // True, Yes, Enables, Set or Activated if (*s == 'T' || *s == 'Y' || *s == 'E' || *s == 'S' || *s == 'A') diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp index 3f46517907..9b1cb42717 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/window.cpp @@ -1257,6 +1257,13 @@ static void wxInsertChildInWindow( wxWindow* parent, wxWindow* child ) { parent->m_sizeSet = FALSE; } + + if (parent->m_windowStyle & wxTAB_TRAVERSAL) + { + /* we now allow a window to get the focus as long as it + doesn't have any children. */ + GTK_WIDGET_UNSET_FLAGS( parent->m_wxwindow, GTK_CAN_FOCUS ); + } } //----------------------------------------------------------------------------- @@ -1421,9 +1428,11 @@ bool wxWindow::Create( wxWindow *parent, wxWindowID id, gtk_viewport_set_shadow_type( viewport, GTK_SHADOW_NONE ); } - if ((m_windowStyle & wxTAB_TRAVERSAL) != 0) + if (m_windowStyle & wxTAB_TRAVERSAL) { - GTK_WIDGET_SET_FLAGS( m_wxwindow, GTK_CAN_FOCUS ); /* changed from UNSET */ + /* we now allow a window to get the focus as long as it + doesn't have any children. */ + GTK_WIDGET_SET_FLAGS( m_wxwindow, GTK_CAN_FOCUS ); m_acceptsFocus = FALSE; } else -- 2.45.2