Unknown Application Crash Under MS Windows Topic is solved

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
ravishi
In need of some credit
In need of some credit
Posts: 4
Joined: Thu Jun 25, 2009 3:21 am

Unknown Application Crash Under MS Windows

Post by ravishi » Thu Jun 25, 2009 3:31 am

Hello, there

I'm new to wxWidgets. I've start dealing with it to develop my first GUI-based program. I've started reading some tutorials, some docs, some manuals and some other reading-things and I got my little first demo program running under Ubuntu Linux.

But I'm not satisfied yet. I want it to run under Windows now. And here I get in trouble. When I compile it, everything works fine, with one exception: my only self-designed dialog does not work. Actually, when I try to open it, my application crashes.

I really don't know where is the problem, since it's running perfectly under Linux and I've developed it with the wxGlade tool (and some extra handy-written code).

So, since I don't even know where to start debuggin or correcting or testing, and so on... I came here!

I'll attach my code (that is really small) and ask for a expert help from you guys.

The MainFrame.cpp creates the main frame from the program, with a toolbar, a menubar and a statusbar. The menu have only two working events: New and Exit. In the OnNew (File->New Project) is the problem. It creates an NewProject dialog, that is all designed in NewProject.cpp. On Windows, it crashes here.

Since now, thank you all for the help.

Regards,
Dirley Rodrigues

-----
Edit

And oh, I almost forgot. I'm compilling it on Windows using MSVC++ Express 2008 with both Debug|Win32 and Unicode Debug|Win32 configurations taken from a sample. I'm also using wxWidgets-2.8.10.
Attachments
MainFrame.cpp
(7.47 KiB) Downloaded 55 times
NewProject.cpp
(4.09 KiB) Downloaded 57 times

protocol
Moderator
Moderator
Posts: 680
Joined: Wed Jan 18, 2006 6:13 pm
Location: Dallas, TX
Contact:

Post by protocol » Thu Jun 25, 2009 5:03 am

When it crashes, what is written to the debug output window?

Are you compiling wxWidgets with the __WXDEBUG__ flag?
/* UIKit && wxWidgets 2.8 && Cocoa && .Net */
QuRegExmm
wxPCRE & ObjPCRE - Regex It!

tan
Moderator
Moderator
Posts: 1471
Joined: Tue Nov 14, 2006 7:58 am
Location: Saint-Petersburg, Russia

Post by tan » Thu Jun 25, 2009 7:03 am

Hi,
it looks like you are using uninitialized pointers (te_title here) in the event handlers:

Code: Select all

void NewProject::OnChangeFolder(wxCommandEvent &event)
{
	if (have_changed_title == false)
	{
		te_title->ChangeValue(te_folder->GetValue());
	}
}
Whether you know, what event handler OnText is called inside the ctor? In this code

Code: Select all

...
    // begin wxGlade: NewProject::NewProject
    label_3 = new wxStaticText(this, wxID_ANY, _("Project folder:"));
    te_folder = new wxTextCtrl(this, ID_INPUT_FOLDER, default_folder);
    label_4 = new wxStaticText(this, wxID_ANY, _("Game title:"));
    te_title = new wxTextCtrl(this, ID_INPUT_TITLE, default_title);
...
OnChangeFolder() will be called before te_title is created.

One of ways to work around:

Code: Select all

...
    te_title = 0;
    te_folder = 0;
    ...
    te_folder = new wxTextCtrl(this, ID_INPUT_FOLDER, default_folder);
    te_title = new wxTextCtrl(this, ID_INPUT_TITLE, default_title);
...
void NewProject::OnChangeFolder(wxCommandEvent &event)
{
	if (have_changed_title == false)
	{
            if( te_title && te_folder )
		te_title->ChangeValue(te_folder->GetValue());
	}
}
OS: Windows XP Pro
Compiler: MSVC++ 7.1
wxWidgets: 2.8.10

ravishi
In need of some credit
In need of some credit
Posts: 4
Joined: Thu Jun 25, 2009 3:21 am

Post by ravishi » Thu Jun 25, 2009 11:03 am

tan wrote:Hi,
it looks like you are using uninitialized pointers (te_title here) in the event handlers [...]
You're right, man! I wasn't attent to that since it was running uder Linux. I did what you told and it worked. Thank you guys for the assistance.

Regards,
Dirley Rodrigues

Post Reply