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
This commit is contained in:
Robert Roebling 1999-01-28 09:57:29 +00:00
parent e85b406c71
commit 3e61c765b5
6 changed files with 84 additions and 40 deletions

View File

@ -451,6 +451,12 @@ void wxApp::CleanUp(void)
delete wxTheApp; delete wxTheApp;
wxTheApp = (wxApp*) NULL; wxTheApp = (wxApp*) NULL;
wxSystemSettings::Done();
delete[] wxBuffer;
wxClassInfo::CleanUpClasses();
/* check for memory leaks */ /* check for memory leaks */
#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT #if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
if (wxDebugContext::CountObjectsLeft() > 0) if (wxDebugContext::CountObjectsLeft() > 0)
@ -466,12 +472,6 @@ void wxApp::CleanUp(void)
wxLog *oldLog = wxLog::SetActiveTarget( (wxLog*) NULL ); wxLog *oldLog = wxLog::SetActiveTarget( (wxLog*) NULL );
if (oldLog) delete oldLog; if (oldLog) delete oldLog;
wxSystemSettings::Done();
wxClassInfo::CleanUpClasses();
delete[] wxBuffer;
} }
wxLog *wxApp::CreateLogTarget() wxLog *wxApp::CreateLogTarget()

View File

@ -57,19 +57,22 @@ extern XrmDatabase wxResourceDatabase;
static char *GetResourcePath(char *buf, char *name, bool create) static char *GetResourcePath(char *buf, char *name, bool create)
{ {
if (create && FileExists(name)) { if (create && FileExists(name))
{
strcpy(buf, name); strcpy(buf, name);
return buf; // Exists so ... return buf; // Exists so ...
} }
if (*name == '/') if (*name == '/')
strcpy(buf, name); strcpy(buf, name);
else { else
{
// Put in standard place for resource files if not absolute // Put in standard place for resource files if not absolute
strcpy(buf, DEFAULT_XRESOURCE_DIR); strcpy(buf, DEFAULT_XRESOURCE_DIR);
strcat(buf, "/"); strcat(buf, "/");
strcat(buf, FileNameFromPath(name)); strcat(buf, FileNameFromPath(name));
} }
if (create) { if (create)
{
// Touch the file to create it // Touch the file to create it
FILE *fd = fopen(buf, "w"); FILE *fd = fopen(buf, "w");
if (fd) fclose(fd); if (fd) fclose(fd);
@ -129,9 +132,12 @@ static void wxXMergeDatabases()
// window when the server initializes and loaded into the display // window when the server initializes and loaded into the display
// structure on XOpenDisplay; // structure on XOpenDisplay;
// if not defined, use .Xdefaults // if not defined, use .Xdefaults
if (XResourceManagerString(GDK_DISPLAY()) != NULL) { if (XResourceManagerString(GDK_DISPLAY()) != NULL)
{
serverDB = XrmGetStringDatabase(XResourceManagerString(GDK_DISPLAY())); serverDB = XrmGetStringDatabase(XResourceManagerString(GDK_DISPLAY()));
} else { }
else
{
(void)GetIniFile(filename, (char *) NULL); (void)GetIniFile(filename, (char *) NULL);
serverDB = XrmGetFileDatabase(filename); serverDB = XrmGetFileDatabase(filename);
} }
@ -141,7 +147,8 @@ static void wxXMergeDatabases()
// Open XENVIRONMENT file, or if not defined, the .Xdefaults, // Open XENVIRONMENT file, or if not defined, the .Xdefaults,
// and merge into existing database // and merge into existing database
if ((environment = getenv("XENVIRONMENT")) == NULL) { if ((environment = getenv("XENVIRONMENT")) == NULL)
{
size_t len; size_t len;
environment = GetIniFile(filename, (const char *) NULL); environment = GetIniFile(filename, (const char *) NULL);
len = strlen(environment); len = strlen(environment);
@ -249,7 +256,8 @@ bool wxGetResource(const wxString& section, const wxString& entry, char **value,
wxXMergeDatabases(); wxXMergeDatabases();
XrmDatabase database; XrmDatabase database;
if ( !file.IsEmpty() ) { if (!file.IsEmpty())
{
char buffer[500]; char buffer[500];
// Is this right? Trying to get it to look in the user's // Is this right? Trying to get it to look in the user's
// home directory instead of current directory -- JACS // 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); bool success = XrmGetResource(database, buf, "*", str_type, &xvalue);
// Try different combinations of upper/lower case, just in case... // 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])); buf[0] = (isupper(buf[0]) ? tolower(buf[0]) : toupper(buf[0]));
success = XrmGetResource(database, buf, "*", str_type, &xvalue); success = XrmGetResource(database, buf, "*", str_type, &xvalue);
} }
if (success) { if (success)
{
if (*value) if (*value)
delete[] *value; delete[] *value;
*value = new char[xvalue.size + 1]; *value = new char[xvalue.size + 1];
@ -297,7 +307,8 @@ bool wxGetResource(const wxString& section, const wxString& entry, float *value,
{ {
char *s = (char *) NULL; char *s = (char *) NULL;
bool succ = wxGetResource(section, entry, &s, file); bool succ = wxGetResource(section, entry, &s, file);
if (succ) { if (succ)
{
*value = (float)strtod(s, (char **) NULL); *value = (float)strtod(s, (char **) NULL);
delete[]s; delete[]s;
return TRUE; return TRUE;
@ -309,7 +320,8 @@ bool wxGetResource(const wxString& section, const wxString& entry, long *value,
{ {
char *s = (char *) NULL; char *s = (char *) NULL;
bool succ = wxGetResource(section, entry, &s, file); bool succ = wxGetResource(section, entry, &s, file);
if (succ) { if (succ)
{
*value = strtol(s, (char **) NULL, 10); *value = strtol(s, (char **) NULL, 10);
delete[]s; delete[]s;
return TRUE; return TRUE;
@ -321,7 +333,8 @@ bool wxGetResource(const wxString& section, const wxString& entry, int *value, c
{ {
char *s = (char *) NULL; char *s = (char *) NULL;
bool succ = wxGetResource(section, entry, &s, file); bool succ = wxGetResource(section, entry, &s, file);
if (succ) { if (succ)
{
// Handle True, False here // Handle True, False here
// True, Yes, Enables, Set or Activated // True, Yes, Enables, Set or Activated
if (*s == 'T' || *s == 'Y' || *s == 'E' || *s == 'S' || *s == 'A') if (*s == 'T' || *s == 'Y' || *s == 'E' || *s == 'S' || *s == 'A')

View File

@ -1257,6 +1257,13 @@ static void wxInsertChildInWindow( wxWindow* parent, wxWindow* child )
{ {
parent->m_sizeSet = FALSE; 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 ); 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; m_acceptsFocus = FALSE;
} }
else else

View File

@ -451,6 +451,12 @@ void wxApp::CleanUp(void)
delete wxTheApp; delete wxTheApp;
wxTheApp = (wxApp*) NULL; wxTheApp = (wxApp*) NULL;
wxSystemSettings::Done();
delete[] wxBuffer;
wxClassInfo::CleanUpClasses();
/* check for memory leaks */ /* check for memory leaks */
#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT #if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
if (wxDebugContext::CountObjectsLeft() > 0) if (wxDebugContext::CountObjectsLeft() > 0)
@ -466,12 +472,6 @@ void wxApp::CleanUp(void)
wxLog *oldLog = wxLog::SetActiveTarget( (wxLog*) NULL ); wxLog *oldLog = wxLog::SetActiveTarget( (wxLog*) NULL );
if (oldLog) delete oldLog; if (oldLog) delete oldLog;
wxSystemSettings::Done();
wxClassInfo::CleanUpClasses();
delete[] wxBuffer;
} }
wxLog *wxApp::CreateLogTarget() wxLog *wxApp::CreateLogTarget()

View File

@ -57,19 +57,22 @@ extern XrmDatabase wxResourceDatabase;
static char *GetResourcePath(char *buf, char *name, bool create) static char *GetResourcePath(char *buf, char *name, bool create)
{ {
if (create && FileExists(name)) { if (create && FileExists(name))
{
strcpy(buf, name); strcpy(buf, name);
return buf; // Exists so ... return buf; // Exists so ...
} }
if (*name == '/') if (*name == '/')
strcpy(buf, name); strcpy(buf, name);
else { else
{
// Put in standard place for resource files if not absolute // Put in standard place for resource files if not absolute
strcpy(buf, DEFAULT_XRESOURCE_DIR); strcpy(buf, DEFAULT_XRESOURCE_DIR);
strcat(buf, "/"); strcat(buf, "/");
strcat(buf, FileNameFromPath(name)); strcat(buf, FileNameFromPath(name));
} }
if (create) { if (create)
{
// Touch the file to create it // Touch the file to create it
FILE *fd = fopen(buf, "w"); FILE *fd = fopen(buf, "w");
if (fd) fclose(fd); if (fd) fclose(fd);
@ -129,9 +132,12 @@ static void wxXMergeDatabases()
// window when the server initializes and loaded into the display // window when the server initializes and loaded into the display
// structure on XOpenDisplay; // structure on XOpenDisplay;
// if not defined, use .Xdefaults // if not defined, use .Xdefaults
if (XResourceManagerString(GDK_DISPLAY()) != NULL) { if (XResourceManagerString(GDK_DISPLAY()) != NULL)
{
serverDB = XrmGetStringDatabase(XResourceManagerString(GDK_DISPLAY())); serverDB = XrmGetStringDatabase(XResourceManagerString(GDK_DISPLAY()));
} else { }
else
{
(void)GetIniFile(filename, (char *) NULL); (void)GetIniFile(filename, (char *) NULL);
serverDB = XrmGetFileDatabase(filename); serverDB = XrmGetFileDatabase(filename);
} }
@ -141,7 +147,8 @@ static void wxXMergeDatabases()
// Open XENVIRONMENT file, or if not defined, the .Xdefaults, // Open XENVIRONMENT file, or if not defined, the .Xdefaults,
// and merge into existing database // and merge into existing database
if ((environment = getenv("XENVIRONMENT")) == NULL) { if ((environment = getenv("XENVIRONMENT")) == NULL)
{
size_t len; size_t len;
environment = GetIniFile(filename, (const char *) NULL); environment = GetIniFile(filename, (const char *) NULL);
len = strlen(environment); len = strlen(environment);
@ -249,7 +256,8 @@ bool wxGetResource(const wxString& section, const wxString& entry, char **value,
wxXMergeDatabases(); wxXMergeDatabases();
XrmDatabase database; XrmDatabase database;
if ( !file.IsEmpty() ) { if (!file.IsEmpty())
{
char buffer[500]; char buffer[500];
// Is this right? Trying to get it to look in the user's // Is this right? Trying to get it to look in the user's
// home directory instead of current directory -- JACS // 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); bool success = XrmGetResource(database, buf, "*", str_type, &xvalue);
// Try different combinations of upper/lower case, just in case... // 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])); buf[0] = (isupper(buf[0]) ? tolower(buf[0]) : toupper(buf[0]));
success = XrmGetResource(database, buf, "*", str_type, &xvalue); success = XrmGetResource(database, buf, "*", str_type, &xvalue);
} }
if (success) { if (success)
{
if (*value) if (*value)
delete[] *value; delete[] *value;
*value = new char[xvalue.size + 1]; *value = new char[xvalue.size + 1];
@ -297,7 +307,8 @@ bool wxGetResource(const wxString& section, const wxString& entry, float *value,
{ {
char *s = (char *) NULL; char *s = (char *) NULL;
bool succ = wxGetResource(section, entry, &s, file); bool succ = wxGetResource(section, entry, &s, file);
if (succ) { if (succ)
{
*value = (float)strtod(s, (char **) NULL); *value = (float)strtod(s, (char **) NULL);
delete[]s; delete[]s;
return TRUE; return TRUE;
@ -309,7 +320,8 @@ bool wxGetResource(const wxString& section, const wxString& entry, long *value,
{ {
char *s = (char *) NULL; char *s = (char *) NULL;
bool succ = wxGetResource(section, entry, &s, file); bool succ = wxGetResource(section, entry, &s, file);
if (succ) { if (succ)
{
*value = strtol(s, (char **) NULL, 10); *value = strtol(s, (char **) NULL, 10);
delete[]s; delete[]s;
return TRUE; return TRUE;
@ -321,7 +333,8 @@ bool wxGetResource(const wxString& section, const wxString& entry, int *value, c
{ {
char *s = (char *) NULL; char *s = (char *) NULL;
bool succ = wxGetResource(section, entry, &s, file); bool succ = wxGetResource(section, entry, &s, file);
if (succ) { if (succ)
{
// Handle True, False here // Handle True, False here
// True, Yes, Enables, Set or Activated // True, Yes, Enables, Set or Activated
if (*s == 'T' || *s == 'Y' || *s == 'E' || *s == 'S' || *s == 'A') if (*s == 'T' || *s == 'Y' || *s == 'E' || *s == 'S' || *s == 'A')

View File

@ -1257,6 +1257,13 @@ static void wxInsertChildInWindow( wxWindow* parent, wxWindow* child )
{ {
parent->m_sizeSet = FALSE; 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 ); 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; m_acceptsFocus = FALSE;
} }
else else