Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Widgets - General questions or Mixed problems » widget lifetime
widget lifetime [message #2133] Sun, 02 April 2006 11:31 Go to next message
gprentice is currently offline  gprentice
Messages: 260
Registered: November 2005
Location: New Zealand
Experienced Member

The UPP website overview page has this

 instead of
struct MyDialog {
    Option *option;
    EditField *edit;
    Button *ok;
};

we are using:

struct MyDialog {
    Option option;
    EditField edit;
    Button ok;
};

Even more important, lifetime of these widgets does not depend 
on the life cycle of MyDialog GUI - MyDialog can be closed 
or not yet open, but attributes of widgets are accessible all 
the time.


I don't follow the argument here. The pointers in the first case can be assigned in the MyDialog constructor and their pointee destroyed in the destructor, giving the same lifecycle as the UPP strategy - or is there some technical reason why toolkits that do the pointer/heap strategy can't do this (which toolkits do the pointer/heap thing - Delphi/BCB/wxWidgets ??).

The pointer/heap way is more code and has the exception safety problem I guess - the destructor isn't called if the constructor didn't complete - means having smart pointers I guess. Hmmm - so is that why these pointers can't be assigned in the MyDialog constructor (unless they're smart pointers) ???

So why don't other toolkits do it the UPP way - does it make the static size of a program bigger?

Where do UPP dialogs normally live - on the stack or on the heap?? - in examples we have MyApp().Run() - which goes on the stack, however stack space is more limited than heap space ??

The UPP web page says the toolkit neither creates or destroys widgets - that means the application does it all ... - so does that mean a UPP application does lots of new'ing and deleting ??

Graeme
[ BTW (fudadmin - are you reading this?) - does preview message work - how do you get back to your message after previewing it? ]
Re: widget lifetime [message #2140 is a reply to message #2133] Sun, 02 April 2006 12:31 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
gprentice wrote on Sun, 02 April 2006 10:31


...
Graeme
[ BTW (fudadmin - are you reading this?) - does preview message work - how do you get back to your message after previewing it? ]


I usually scroll using vertical scrollbar of my Opera... What is a problem?
Re: widget lifetime [message #2142 is a reply to message #2140] Sun, 02 April 2006 12:40 Go to previous messageGo to next message
gprentice is currently offline  gprentice
Messages: 260
Registered: November 2005
Location: New Zealand
Experienced Member
fudadmin wrote on Sun, 02 April 2006 22:31

gprentice wrote on Sun, 02 April 2006 10:31


...
Graeme
[ BTW (fudadmin - are you reading this?) - does preview message work - how do you get back to your message after previewing it? ]


I usually scroll using vertical scrollbar of my Opera... What is a problem?


uh, um well, I'm used to an app we have at work that requires browser back button after preview, so that's what I did and something went wrong (I think, anyway I restarted my post) - but I just tried it again on this message and it seemed to work ok - so now I'm trying the vertical scrollbar way - works too - ok, cool. (using Mozilla)

Graeme
Re: widget lifetime [message #2156 is a reply to message #2133] Sun, 02 April 2006 15:46 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
[quote title=gprentice wrote on Sun, 02 April 2006 05:31]
The UPP website overview page has this

 instead of
struct MyDialog {
    Option *option;
    EditField *edit;
    Button *ok;
};

we are using:

struct MyDialog {
    Option option;
    EditField edit;
    Button ok;
};

Even more important, lifetime of these widgets does not depend 
on the life cycle of MyDialog GUI - MyDialog can be closed 
or not yet open, but attributes of widgets are accessible all 
the time.


Quote:


I don't follow the argument here. The pointers in the first case can be assigned in the MyDialog constructor and their pointee destroyed in the destructor, giving the same lifecycle as the UPP strategy - or is there some technical reason why toolkits that do the pointer/heap strategy can't do this (which toolkits do the pointer/heap thing - Delphi/BCB/wxWidgets ??).



First those are two distinct (albeit related) features (no pointers and lifetime not limited by toolkit).

Second, yes, you could do destruction in destructor, but that would be a lot of code to write. In fact, you CAN do that if you want with U++.

As for other toolkits - any other C++ toolkit known to me REQUIRES widgets to reside on heap. I most cases, the reason is exactly because it is a lot of work to delete them manually, so toolkit takes care about deleting of widgets (therefore they MUST be on the heap). And of course, as there needs to be a point of deletion, widgets are usually deleted when GUI lifecycle ends (dialog closed). Kind of architectural deadlock, which we refused to share Wink

Quote:


So why don't other toolkits do it the UPP way - does it make the static size of a program bigger?



Somebody had to be first Smile

Also besides argument already presented, worth noting is that this architecture is only possible with C++. Other toolkits often follow non-C++ widget architecture models (e.g. taken from C or Java...).

Quote:


Where do UPP dialogs normally live - on the stack or on the heap?? - in examples we have MyApp().Run() - which goes on the stack, however stack space is more limited than heap space ??



You have to difer "inteface" and "implementation" part of thing. "interface"-like live usually on stack, however "implementation" often uses the heap (usually via NTL containers and String/Value and other concrete classes).

Quote:


The UPP web page says the toolkit neither creates or destroys widgets - that means the application does it all ... - so does that mean a UPP application does lots of new'ing and deleting ??



Have you seen some new or delete in examples or TheIDE sources? Smile

Most of real heap deletes is in fact performed by NTL and String implementations. However, at interaface level, using pointers to manage heap resources is a "bad practice" and most of client code does not have to care about heap.

Mirek
Previous Topic: How to change the theme [PARTLY SOLVED...]
Next Topic: TreeCtrl and ArrayCtrl - how to invoke editor for individual items? [SOLVED...]
Goto Forum:
  


Current Time: Thu Mar 28 16:42:33 CET 2024

Total time taken to generate the page: 0.01750 seconds