Skip to content

[wxDialog] Crashing on ShowModal() #46

Description

@HenriVi

Hi,

calling ShowModal in dialogs OnInit() goes on to perpetual loop that eventually crashes the program when stack runs out.

Example:

SuperStrict

Framework wx.wxApp

Import wx.wxFrame
Import wx.wxDialog
Import wx.wxPanel
Import wx.wxStaticText
Import wx.wxTextCtrl

'Run application
New TApp.run()

Type TApp Extends wxApp
	
	Global myframe:wxFrame
	
	Method OnInit:Int()
			
		myframe	= wxFrame(New wxFrame.Create(Null, wxID_ANY, "Dialog example", - 1, - 1, 200, 200, wxDEFAULT_FRAME_STYLE | wxTAB_TRAVERSAL) )
		myframe.show()
		
		Local value:String = EntryDlg("Testing", "Value")
		Print value
		
		Return True
	End Method

End Type


Function EntryDlg:String(text:String, title:String)

	Local dial:TEntryDialog = New TEntryDialog.Create(text, title)
	Local value:String = dial.GetString()

	dial.Free()
	Return value

EndFunction

Type TEntryDialog Extends wxDialog

	Field m_panel:wxPanel
	Field m_field1:wxTextCtrl
	Field text:String
	Field value:String
	
	Global _ret:Int
	
	Method Create:TEntryDialog(txt:String, title:String)
		text = txt
		Return TEntryDialog(Super.Create_(Null, wxID_ANY, title, -1, -1, -1, -1, wxDEFAULT_DIALOG_STYLE))
	End Method

	Method OnInit:Int()
		
		Local bSizer1:wxBoxSizer = New wxBoxSizer.Create(wxVERTICAL)
		
		'Using wxPanel creates a perpetual loop between wxPanels and wxWindows TransferData
		m_panel = New wxPanel.Create(Self, wxID_ANY,,,,, wxTAB_TRAVERSAL)
		
		m_field1 = New wxTextCtrl.Create(m_panel, wxID_ANY, "",,,200,,0)
		bSizer1.Add(m_field1, 1, wxRIGHT|wxLEFT|wxTOP|wxBOTTOM, 5)
		
		m_panel.SetSizer(bSizer1)
		Layout()
		bSizer1.Fit(Self)
		Center(wxBOTH)
		
		_ret = ShowModal()
		
	End Method
	
	Method GetString:String()
		Return value
	EndMethod
	
End Type

-Henri

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions