wxFileDialog segmentation fault

This forum can be used to talk about general design strategies, new ideas and questions in general related to wxWidgets. If you feel your questions doesn't fit anywhere, put it here.
Post Reply
SveT
Knows some wx things
Knows some wx things
Posts: 37
Joined: Tue Feb 07, 2006 1:56 pm

wxFileDialog segmentation fault

Post by SveT »

Hi,

I have a simple file dialog, as given in the dialogs.cpp example.

The problem is that when I try to show the dialog, sometimes it crashes, sometimes not. If it is shown and I try to change the directory - again, random crashes and random success.

So at all from 10 executions, I am able to select the file I wish to only once.

Any ideas?

P.S.
I am using wxWidgets 2.6.2 compiled with gcc.3.3.5 on Mandriva 2006.
I can not use other compiler, because I use a library, which come precompiled with gcc.3.3.5
phlox81
wxWorld Domination!
wxWorld Domination!
Posts: 1387
Joined: Thu Aug 18, 2005 7:49 pm
Location: Germany
Contact:

Post by phlox81 »

Hm, compile wxWidgets new, or is it a different precompiled lib ?

For your crashes, it is probably something in your code,
a unvalid pointer etc. Could you show us your code ?
SveT
Knows some wx things
Knows some wx things
Posts: 37
Joined: Tue Feb 07, 2006 1:56 pm

Post by SveT »

Here is the code

Code: Select all

void ONS_Panel::FileBrowser(wxCommandEvent &event)
{
    wxString _message;
    switch (event.GetId())
    {
	case ID_BUTTON_NETWORK_TOPOLOGY:
	{
	    _message=_T("Choose a Network Topology File ...");
	}
	break;
	case ID_BUTTON_NETWORK_DEMAND:
	{
	    _message=_T("Choose a Network Demand File ...");
	}
	break;
    }
    
    wxFileDialog *fileDialog = new wxFileDialog(_parentFrame, _message, wxGetCwd(), wxEmptyString, _T("GML files (*.gml)|*.gml|All Files (*.*)|*.*"));
    fileDialog->CentreOnParent();
    int _pathLength = wxGetCwd().Length();
    if (fileDialog->ShowModal() == wxID_OK )
    {
	switch (event.GetId())
	{
	    case ID_BUTTON_NETWORK_TOPOLOGY:
	    {
		_fileNetworkTopology->Clear();
		wxString info = fileDialog->GetPath();
		_fileNetworkTopology->WriteText(info.SubString(_pathLength+1,info.Length()));
    	    }
	    break;
	    case ID_BUTTON_NETWORK_DEMAND:
	    {
		_fileNetworkDemand->Clear();
		wxString info = fileDialog->GetPath();
		_fileNetworkDemand->WriteText(info.SubString(_pathLength+1,info.Length()));
	    }
	    break;
	}	
    }
    
}

All the variables are declared and there is no problem with them.

I was just wondering whether I should use some specific options with the configure script.

I have used the following:

./configure --with-gtk --disable-precompiled headers
sglow
In need of some credit
In need of some credit
Posts: 2
Joined: Sun Mar 12, 2006 2:09 pm

Post by sglow »

I'm running into the same problem on a Gentoo Linux system. In fact, I see the crash every time I try to open a wxFileDialog on any application, not just the ones that I create. This goes for dialogblocks and audacity as well as my own code.

I've logged a bug (number 1440312) on the issue, but so far there has been no activity. I've also tried to step through the code to see if I can find out what's going wrong, but the segfault doesn't happen when I step through the wxFileDialog code, so it's probably a timing issue.

Has anyone else run into this problem?

Thanks,
Steve
leio
Can't get richer than this
Can't get richer than this
Posts: 802
Joined: Mon Dec 27, 2004 10:46 am
Location: Estonia, Tallinn
Contact:

Post by leio »

I simply could never reproduce this. Neither bug 1287999 or your reported one.
Compilers: gcc-3.3.6, gcc-3.4.5, gcc-4.0.2, gcc-4.1.0 and MSVC6
OS's: Gentoo Linux, WinXP; WX: CVS HEAD

Project Manager of wxMUD - http://wxmud.sf.net/
Developer of wxGTK;
gtk+ port maintainer of OMGUI - http://www.omgui.org/
soban
In need of some credit
In need of some credit
Posts: 5
Joined: Wed Dec 14, 2005 2:56 pm
Contact:

Post by soban »

sglow wrote:I'm running into the same problem on a Gentoo Linux system. In fact, I see the crash every time I try to open a wxFileDialog on any application, not just the ones that I create. This goes for dialogblocks and audacity as well as my own code.

I've logged a bug (number 1440312) on the issue, but so far there has been no activity. I've also tried to step through the code to see if I can find out what's going wrong, but the segfault doesn't happen when I step through the wxFileDialog code, so it's probably a timing issue.

Has anyone else run into this problem?

Thanks,
Steve
well maybe it's something completely different, but I had problems with wxFileDialogs on Debian Sarge. Usually my app freezed, when I'd tried to create a wxFileDialog, but sometimes not... I remembered that in the "past" it worked fine. The difference between past and present was in some system updates, kernell recompiles etc., so I've decided to recompile wxGTK again and now it seems that it works fine again...that's all I can say about this problem:)
...I have to learn a lot about Linux and wxWidgets...
running Debian Sarge on IBM ThinkPad R50e PM1,6, trying to develop one crossplatform app for documentation management
Post Reply