LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-28-2002, 03:03 AM   #1
luigi
LQ Newbie
 
Registered: Aug 2001
Location: Italy
Distribution: kubuntu
Posts: 27

Rep: Reputation: 15
Question libjpeg error handling


I'm writing a gtk-- program (so, signal-slot mechanism) to handle jpeg images and something else.
The problem now is that i want to catch errors from libjpeg not to have the exit() called, for example:

The users click: File->Open New Jpeg->
And he clicks on a non-jpeg file: the befault behaviour for libjpeg is to write something like
"not a jpeg file" and call exit().

The libjpeg docs say:
"
Error handling
--------------

When the default error handler is used, any error detected inside the JPEG
routines will cause a message to be printed on stderr, followed by exit().
You can supply your own error handling routines to override this behavior
and to control the treatment of nonfatal warnings and trace/debug messages.
The file example.c illustrates the most common case, which is to have the
application regain control after an error rather than exiting.

The JPEG library never writes any message directly; it always goes through
the error handling routines. Three classes of messages are recognized:
* Fatal errors: the library cannot continue.
* Warnings: the library can continue, but the data is corrupt, and a
damaged output image is likely to result.
* Trace/informational messages. These come with a trace level indicating
the importance of the message; you can control the verbosity of the
program by adjusting the maximum trace level that will be displayed.

.... you can override functions ....

The individual methods that you might wish to override are:

error_exit (j_common_ptr cinfo)
Receives control for a fatal error. Information sufficient to
generate the error message has been stored in cinfo->err; call
output_message to display it. Control must NOT return to the caller;
generally this routine will exit() or longjmp() somewhere.
Typically you would override this routine to get rid of the exit()
default behavior. Note that if you continue processing, you should
clean up the JPEG object with jpeg_abort() or jpeg_destroy().


".



I have done that, in the sense that i see my little MyErrorExit() function writing "hello! i'm here" but, after doing something, the control returns to the caller, and it exit() or start looping, depending to what i 've done inside MyErrorExit() (later if you want i can paste it)

Any ideas??

Thanks
Luigi


__
 
Old 04-19-2005, 04:43 AM   #2
jcaga
LQ Newbie
 
Registered: Apr 2005
Location: philippines
Posts: 8

Rep: Reputation: 0
libjpeg error handling

I have tried diving in the djpeg code and I could suggest that we are to modify the code so it will not forcibly terminate the program. It may take time to do this this is what I intend to do since I am also encountering somewhat similar problem as yours. I am still looking for someone who would agree with me on doing this.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
c++ opendir() handling error bendeco13 Programming 1 11-06-2005 02:37 AM
error: "cannot find libjpeg support" Lokathor Debian 3 11-04-2005 06:12 PM
xinetd error handling iftiuk Linux - Networking 0 04-21-2004 02:32 PM
Perl Error Handling Crashed_Again Programming 1 01-21-2004 02:25 PM
error compiling looking for libjpeg bosewicht Linux - Newbie 1 01-04-2004 04:10 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:20 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration