Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wxDialog] Crashing on ShowModal() #46

Open
HenriVi opened this issue May 6, 2020 · 4 comments
Open

[wxDialog] Crashing on ShowModal() #46

HenriVi opened this issue May 6, 2020 · 4 comments

Comments

@HenriVi
Copy link

HenriVi commented May 6, 2020

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

@HenriVi
Copy link
Author

HenriVi commented May 11, 2020

Update:

If I compile without using wxPanel it works. This leads me to believe that November 15, 2018 update (Added support for data transfer callbacks.) was the one causing this issue.

-Henri

@GWRon
Copy link
Contributor

GWRon commented May 11, 2020

7a04c79

so manually undoing or "commenting out" the function content resolves the issue?

Maybe it uses some "handles" internally - which are not yet assigned when OnInit is called?

@HenriVi
Copy link
Author

HenriVi commented May 11, 2020

Hi Ron,

I did not try to comment out the functions added in the update, but simple did not use the wxPanel in creating the dialog, as I did notice the program flow was bouncing between the added datatransfer function in the wxPanel and the related function in wxWindow.

In any case, the fix lies in editing the wxPanel. I'll try to test that next..

-Henri

@HenriVi
Copy link
Author

HenriVi commented Jun 6, 2020

Finally got around to it..

Okay, I commented out the transferdata-methods in wxpanel.bmx, glue.cpp and glue.h files and this fixes the problem.

Not sure what prompted Brucey to add them in the first place, but so far I haven't come across any problems using code without them.

I also made the example code a bit leaner and more precise to the issue

-Henri

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants