Whither DWT? (wxD)

Anders F Björklund afb at algonet.se
Sat Apr 22 14:59:24 PDT 2006


kris wrote:

>> I think one of the gripes that people *seem* to have about SWT (& DWT)
>> is that the resources aren't garbage collected but need to be managed ?
> 
> Hehe; that's what makes it perfectly suited to D :)

Yeah, the comments were actually from Java (should have read "(& DWT?)",
as I am not very familiar with the differences between SWT and DWT...)

Think it was mostly a critic from proponents of Swing instead of SWT ?
Here was one: http://cld.blog-city.com/comparing_swt_and_swing.htm

I think that you're right that explicit calls are easier to handle in D.

> (relying on the D GC/dtor construct to release all resources would 
> simply result in seg-faults -- I imagine you'll run into this with wxD, 
> if any of the relevant resources are also GC managed)

It has some kind of global wx object registry that keeps track of them,
and I think most of that system was actually ported over from C#... :-)
But in the C++ wrappers, there is usually one ***_ctor and one ***_dtor.
It would be nice if it could be GC'd, but for now it's new and delete.


Looks something like this, in the C++ code:

extern "C" WXEXPORT
wxString* wxString_ctor(const char* str)
{
	return new _wxString(str, wxConvUTF8);
}

extern "C" WXEXPORT
void wxString_dtor(wxString *self)
{
	if (self != NULL)
		delete self;
}

(_wxString is a wrapper class for wxString)


I *think* wxD could be OK with D, asthe external "wxobj" is allocated
outside of the D garbage collector (which should be OK then, right ?)
i.e. as long as you use "auto" objects, or explicit deletes on them...
But we definitely need to dig in deeper in this, before any release.

As I believe that this matter could be a contributor to the wxD crashes,
I understand that the garbage collector works differently in D and C# ?


Maybe Bero can shed some more light on the inner wxD workings of this ?

--anders



More information about the Digitalmars-d-dwt mailing list