Strange lockup Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
xee
Earned a small fee
Earned a small fee
Posts: 10
Joined: Sat Feb 19, 2005 9:26 pm

Strange lockup

Post by xee »

I'm facing a very strange lockup, couldn't determine who's problem is it(mine or wx's).

The lockup happens as soon as the selection is changed from any of the radio's to the other, and then you have to close the application forcefully.

below is the code that shows this problem, it happens whether it is compiled with wx 2.6.2, 2.6.3, or even 2.8, I noticed that as soon as the wxEditableListBox is removed, the bug disappears, but I'm almost sure that it's not a problem with wxEditableListBox itself because I used it on a previous project and it worked fine.

you can comment the 2 marked lines to remove the bug.

here's main.cpp

Code: Select all

// -*- C++ -*- generated by wxGlade 0.4 on Fri Mar 10 03:29:47 2006

#include <wx/wx.h>
#include <wx/image.h>
#include "RegistrationDialog.h"

class MyApp: public wxApp
	{
	public:
		bool OnInit();
	};

IMPLEMENT_APP(MyApp)

bool MyApp::OnInit()
	{
    wxInitAllImageHandlers();

    RegistrationDialog dlg;
    dlg.ShowModal();

    return false;
	}
and here's the the file containing the wxDialog-derived class:

Code: Select all


// -*- C++ -*- generated by wxGlade 0.4.1 on Sun Apr 23 13:59:08 2006

#include <wx/wx.h>
#include <wx/gizmos/editlbox.h>

class RegistrationDialog: public wxDialog
	{
	public:
	RegistrationDialog();

	private:
    // begin wxGlade: RegistrationDialog::methods
    void set_properties();
    void do_layout();
    // end wxGlade

	protected:
    // begin wxGlade: RegistrationDialog::attributes
    wxEditableListBox* _fixedPhonesEditableLBox;
    wxRadioButton* _noTransferRadioButton;
    wxRadioButton* _transferedFromCenterToAgent;
    // end wxGlade
	}; // wxGlade: end class

// -*- C++ -*- generated by wxGlade 0.4.1 on Sun Apr 23 13:59:08 2006

RegistrationDialog::RegistrationDialog():
    wxDialog(NULL, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxCAPTION|wxSYSTEM_MENU|wxRESIZE_BORDER|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxCLOSE_BOX|wxCLIP_CHILDREN)
	{
    // begin wxGlade: RegistrationDialog::RegistrationDialog
    _fixedPhonesEditableLBox = new wxEditableListBox(this, -1, wxT("Fixed Phones")); // comment this line to remove bug
    _noTransferRadioButton = new wxRadioButton(this, -1, _("No transfers"));
    _transferedFromCenterToAgent = new wxRadioButton(this, -1, _("Transfered from center to agent"));

    set_properties();
    do_layout();
    // end wxGlade
	}

void RegistrationDialog::set_properties()
	{
    // begin wxGlade: RegistrationDialog::set_properties
    SetTitle(_("Register Donor"));
    _noTransferRadioButton->SetValue(1);
    // end wxGlade
	}

void RegistrationDialog::do_layout()
	{
    // begin wxGlade: RegistrationDialog::do_layout
    wxBoxSizer* _mainSizer = new wxBoxSizer(wxVERTICAL);
    wxGridSizer* grid_sizer_1 = new wxGridSizer(4, 1, 0, 0);
    _mainSizer->Add(_fixedPhonesEditableLBox, 1, wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0); // comment this line to remove bug
    grid_sizer_1->Add(_noTransferRadioButton, 0, wxALL|wxALIGN_CENTER_VERTICAL, 4);
    grid_sizer_1->Add(_transferedFromCenterToAgent, 0, wxALL|wxALIGN_CENTER_VERTICAL, 4);
    _mainSizer->Add(grid_sizer_1, 0, wxEXPAND, 0);
    SetAutoLayout(true);
    SetSizer(_mainSizer);
    _mainSizer->Fit(this);
    _mainSizer->SetSizeHints(this);
    Layout();
    Centre();
    // end wxGlade
	}

here's how the application looks:
Image

here are the binaries, with and without the wxEditableListBox, so you can try them immediately, and here's the sourceif you'd like to compile

thanks in advance

notes:
  • I did some last minute edits to the source to make it shorter and more readable, so if you find any so-obvious mistakes, then they weren't there.
  • All of this code was generated by wxGlade 4.1, which makes me assume there's no problem with the code.
  • wxEditableListBox is part of contrib/gizmos, to compile the above sourcecode, you must have contrib/gizmos compiled(which needs wxUSE_MDI set, in setup.h).
megabyte
I live to help wx-kind
I live to help wx-kind
Posts: 196
Joined: Tue Dec 07, 2004 8:54 pm
Location: Essen, Germany

Post by megabyte »

Start your program under a debugger and pause the debugger after the lock. Tracing the call stack and some breakpoints help you to find out the lock cause.
xee
Earned a small fee
Earned a small fee
Posts: 10
Joined: Sat Feb 19, 2005 9:26 pm

Post by xee »

megabyte wrote:Start your program under a debugger and pause the debugger after the lock. Tracing the call stack and some breakpoints help you to find out the lock cause.
Thanks for the help, I've already done so, but this was while using wx 2.6.3, and it didn't get me anywhere, I've tried to do so again today, however using wx 2.8 branch, and I found out that the window keeps receiving WM_GETDLGCODE repeatedly, and never stops, I got a 44 megs log file after 3 seconds of running.

here are the 2 lines getting repeated from the log file:

17:51:28: Trace: Processing WM_GETDLGCODE(hWnd=00040a44, wParam= 0, lParam= 0)
17:51:28: Trace: Forwarding WM_GETDLGCODE to DefWindowProc.

any idea why is this happening?
xee
Earned a small fee
Earned a small fee
Posts: 10
Joined: Sat Feb 19, 2005 9:26 pm

Solved...

Post by xee »

Well, I've found the problem, and the solution, it's a bug in wx that happens in some special cases with wxRadioButton.
The bug has been there for a while, check this post for more details.
The proposed solution doesn't work for me because they're all one group, I can't use wxRB_SINGLE as it'd make any of them in a single group(but it solves the bug).

so I just gave it a try and placed the radio buttons inside a wxPanel, and it solved the problem.
Post Reply