Disable exception

For help with anything that CEGUI doesn't offer straight out-of-the-box, e.g.:
- Implementation of new features, such as new Core classes, widgets, WindowRenderers, etc. ...
- Modification of any existing features for specific purposes
- Integration of CEGUI in new engines or frameworks and writing of new plugins (Renderer, Parser, ...) or modules

Moderators: CEGUI MVP, CEGUI Team

hermit purple
Just popping in
Just popping in
Posts: 13
Joined: Wed Oct 21, 2009 20:21

Disable exception

Postby hermit purple » Fri Oct 23, 2009 22:49

I'm porting CEGUI to PS3 and I encounter a problem.

It seems that PS3 disable support for exception handling. So the code will not compile when it see CEGUI code.

There are some info about using _HAS_EXCEPTIONS to disable STL dll but I'm not sure if that does anything since I'm getting compile error, not linking, not run-time.

Is there a way to disable exception build-in in CEGUI? or should I just manually comment out all throw lines?

Jamarr
CEGUI MVP
CEGUI MVP
Posts: 812
Joined: Tue Jun 03, 2008 23:59
Location: USA

Re: Disable exception

Postby Jamarr » Fri Oct 23, 2009 23:00

Hi. As far as I know there is nothing currently built into CEGUI to disable exception handling. I know that this topic has been discussed previously and CE seemed discouraged to add this. Searching for "disabling exceptions" brought up this thread in particular. It sounds like CE is open to some persuasion in regards to this.
If somebody helps you by replying to your thread, upvote him/her as a thanks! Make sure to include your CEGUI.log and everything you tried when posting! And remember that we are not magicians!

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: Disable exception

Postby CrazyEddie » Sat Oct 24, 2009 08:09

Yeah, currently commenting affected constructs will be the way to go. As Jamarr mentioned, this is something were considering based on the thread linked; it's not a facility I like adding, because such things unfortunately get abused by noobs and we're left to pick up the pieces. It will likely go in at some stage though (either a later 0.7.x point or more likely for the 0.8.0 release).

CE.

hermit purple
Just popping in
Just popping in
Posts: 13
Joined: Wed Oct 21, 2009 20:21

Re: Disable exception

Postby hermit purple » Mon Oct 26, 2009 14:31

Will commenting out throw lines effect how CEGUI work? What I'm asking is, does CEGUI use exception for regular operation? or only use exception for error handling?

If it's just for error handling, then I assume it would be safe to remove them since we wouldn't run into these errors on final release. But it would be a different story if it use exception to do basic window operation.

User avatar
scriptkid
Home away from home
Home away from home
Posts: 1178
Joined: Wed Jan 12, 2005 12:06
Location: The Hague, The Netherlands
Contact:

Re: Disable exception

Postby scriptkid » Tue Oct 27, 2009 09:14

[edit] Some answers first:
Cegui has already been made more forgiving, and some exceptions have been removed. So generally, exceptions are only used for fatal things now.
[/edit]

When you disable a 'throw', the code will continue, which is unwanted. Just returning isn't always possible either, because then the client code doesn't know something went wrong.

Most 'severe' functions however do return something; a window, an imageset, a font and so on. So you could turn part of the code in a way that your client checks for not-null after such calls. Of course, meaning that instead of a throw, you return a NULL.

For the 'void' functions, you could rely on on a sort of Set/Get last error, like some C-style API's do. So before returning (in stead of throwing) you can set a last error, like

Code: Select all

CEGUISetLastError("DefaultResourceProvider::load - Filename supplied for data loading must be valid");


And then in your client call, you check for an error flag.

HTH.

Btw it's cool to read that you are working (or at least trying to!) with Cegui on a console :)
Check out my released snake game using Cegui!

Jamarr
CEGUI MVP
CEGUI MVP
Posts: 812
Joined: Tue Jun 03, 2008 23:59
Location: USA

Re: Disable exception

Postby Jamarr » Tue Oct 27, 2009 20:33

I'm fairly certain that you can enable exceptions on the PS3?

Anyway, I really cannot see supporting error-codes/error-states as a viable alternative to exceptions. How would you support both error handling techniques simultaneously? I can only imagine it being a nightmare.

The best options I can see are:
  1. A simple macro as proposed in the linked thread, though with CEGUI_THROW always calling terminate().
  2. Using C's setjmp/longjmp (eg cexcept) though that comes with it's own pitfalls...
If somebody helps you by replying to your thread, upvote him/her as a thanks! Make sure to include your CEGUI.log and everything you tried when posting! And remember that we are not magicians!

User avatar
scriptkid
Home away from home
Home away from home
Posts: 1178
Joined: Wed Jan 12, 2005 12:06
Location: The Hague, The Netherlands
Contact:

Re: Disable exception

Postby scriptkid » Wed Oct 28, 2009 08:52

Hi,

Of course my suggestion for the error-codes was merely a local change on his own machine. Not something i would see valid for a future Cegui enhancement :)

Calling 'exit' might be a good option too, especially when it's a product baked onto a disc, when cegui's kind of exceptions are pretty unlikely to happen.
Check out my released snake game using Cegui!

hermit purple
Just popping in
Just popping in
Posts: 13
Joined: Wed Oct 21, 2009 20:21

Re: Disable exception

Postby hermit purple » Wed Oct 28, 2009 23:37

Thanks for all the reply.

It looks like it's save to replace exception with termination. CEGUI doesn't seem to use exception other than error reporting.

And yes, PS3 does have exception support but devil always lies in the details. In this case, it depends on which CPU you use, and in certain case it may violate the TRC.


Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: No registered users and 10 guests