Bug 276154

Summary: jpegutils.cpp contains debug output, but disabled by define
Product: [Applications] digikam Reporter: Peter Albrecht <px79>
Component: Import-Gphoto2Assignee: Digikam Developers <digikam-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: caulier.gilles
Priority: NOR    
Version: 2.0.0   
Target Milestone: ---   
Platform: Gentoo Packages   
OS: Linux   
Latest Commit: Version Fixed In: 2.0.0
Sentry Crash Report:

Description Peter Albrecht 2011-06-20 23:11:30 UTC
Version:           2.0.0 (using Devel) 
OS:                Linux

I have got a problem with jpeg autorotation at import from a camera sd card. See bug #274947. Autorotate seems to fail, but there is no error message at STDOUT/STDERR.

Debugging the process lead me to
> /var/tmp/portage/media-gfx/digikam-2.0.0_beta6/work/digikam-2.0.0-beta6/core/libs/jpegutils/jpegutils.cpp, line 94
------------------ 8< ------------------ 
static void jpegutils_jpeg_error_exit(j_common_ptr cinfo)
{
    jpegutils_jpeg_error_mgr* myerr = (jpegutils_jpeg_error_mgr*) cinfo->err;

    char buffer[JMSG_LENGTH_MAX];
    (*cinfo->err->format_message)(cinfo, buffer);

#ifdef ENABLE_DEBUG_MESSAGES
    kDebug() << buffer;
#endif

    longjmp(myerr->setjmp_buffer, 1);
}
------------------ >8 ------------------ 

There I can see "kDebug() << buffer;", which would write the desired error output. But ENABLE_DEBUG_MESSAGES is not defined. It's commented out in line 83:
> //#define ENABLE_DEBUG_MESSAGES

Why should one not want to see an error message, if an error occured? Seeing an error message might have helped debugging the problem.

I enabled the gentoo "debug" USE-flag for digikam, hoping that this would magically define ENABLE_DEBUG_MESSAGES. But that did not happen.

Maybe I just don't understand all KDE-debugging guidelines. 
I'm aware of kdebugdialog and I like the concept very much! :)
But I don't understand the above issue.
Can you bring light to this issue, please? Thx!

Reproducible: Always


Actual Results:  
No error message, although error happened and is detected by the programm.

Expected Results:  
Error message is printed out to STDOUT or STDERR.
Comment 1 Peter Albrecht 2011-06-20 23:16:21 UTC
I forgot to mention Bug #139197, where you can find related info in comments 7 and 10.

Please don't misunderstand me. I don't want to be a smart ass. I admire you guys, putting all this stuff together, creating almost wonders! 

I just want to understand how things work.
Comment 2 caulier.gilles 2011-06-21 09:00:22 UTC
It's simple. Just use this option to pass on cmake script when you configure : "-DENABLE_DEBUG_MESSAGES"

Gilles Caulier
Comment 3 Peter Albrecht 2011-06-21 20:14:34 UTC
(In reply to comment #2)
> It's simple. Just use this option to pass on cmake script when you configure :
> "-DENABLE_DEBUG_MESSAGES"

Thanks for the info. 

@Gentoo:
So I would say, this flag should be enabled, if the gentoo USE flag "debug" is enabled. Which is not the case for media-gfx/digikam-2.0.0_beta6.
Any gentoo maintainer for media-gfx/digikam-2.0.0_beta6 ebuild listening? Or do I have to file a separate gentoo bug?
Comment 4 Andreas K. Huettel 2011-06-21 21:43:46 UTC
(In reply to comment #3)
> (In reply to comment #2)
> > It's simple. Just use this option to pass on cmake script when you configure :
> > "-DENABLE_DEBUG_MESSAGES"
> 
> Thanks for the info. 
> 
> @Gentoo:
> So I would say, this flag should be enabled, if the gentoo USE flag "debug" is
> enabled. Which is not the case for media-gfx/digikam-2.0.0_beta6.

That was a one-liner. Re-sync your overlay and it should work (with USE=debug).
Comment 5 Peter Albrecht 2011-06-23 20:53:48 UTC
Synchronized overlay and rebuild digikam with USE=debug.

build.log says "-DENABLE_DEBUG_MESSAGES=ON":
--------------------- 8< ---------------------
> ...
> cmake --no-warn-unused-cli -C /var/tmp/portage/media-gfx/digikam-2.0.0_beta6/temp/gentoo_common_config.cmake -DCMAKE_INSTALL_PREFIX=/usr -DKDE4_BUILD_TESTS=OFF -DCMAKE_INSTALL_PREFIX=/usr -DSYSCONF_INSTALL_DIR=/etc -DFORCED_UNBUNDLE=ON -DWITH_LQR=ON -DWITH_LENSFUN=ON -DGWENVIEW_SEMANTICINFO_BACKEND=Nepomuk -DWITH_KdepimLibs=OFF -DWITH_MarbleWidget=ON -DENABLE_GPHOTO2=ON -DWITH_gphoto2=ON -DWITH_GPHOTO2=ON -DWITH_Gphoto2=ON -DWITH_Soprano=ON -DENABLE_themedesigner=OFF -DENABLE_THEMEDESIGNER=OFF -DENABLE_Themedesigner=OFF -DENABLE_THUMBS_DB=ON -DENABLE_DEBUG_MESSAGES=ON -DCMAKE_BUILD_TYPE=Debugfull -DCMAKE_INSTALL_DO_STRIP=OFF -DCMAKE_USER_MAKE_RULES_OVERRIDE=/var/tmp/portage/media-gfx/digikam-2.0.0_beta6/temp/gentoo_rules.cmake  /var/tmp/portage/media-gfx/digikam-2.0.0_beta6/work/digikam-2.0.0-beta6/core
> ...
--------------------- >8 ---------------------

But error message is still not printed. :(
Using gdb to step through execution does not reach line 
> kDebug() << buffer;
So I guess ENABLE_DEBUG_MESSAGES is not defined, when compiling 
> /var/tmp/portage/media-gfx/digikam-2.0.0_beta6/work/digikam-2.0.0-beta6/core/libs/jpegutils/jpegutils.cpp
Comment 6 caulier.gilles 2011-07-01 15:34:11 UTC
Git commit 7d195f5096981cd8e32627e1de8d6710b2b5db88 by Gilles Caulier.
Committed on 01/07/2011 at 17:32.
Pushed by cgilles into branch 'master'.

add a new cmake option to enable advanced debug statements for all image loaders at compilation time.
Use -DENABLE_ADVANCEDDEBUGMSG=yes with cmake.
BUGS: 276154

M  +5    -3    CMakeLists.txt     
M  +5    -3    README     
M  +3    -0    digikam/utils/config-digikam.h.cmake     
M  +2    -6    libs/dimg/loaders/jp2kloader.cpp     
M  +6    -10   libs/dimg/loaders/jpegloader.cpp     
M  +3    -8    libs/dimg/loaders/pgfloader.cpp     
M  +20   -24   libs/dimg/loaders/pngloader.cpp     
M  +3    -8    libs/dimg/loaders/ppmloader.cpp     
M  +5    -9    libs/dimg/loaders/tiffloader.cpp     
M  +3    -5    libs/jpegutils/jpegutils.cpp     

http://commits.kde.org/digikam/7d195f5096981cd8e32627e1de8d6710b2b5db88
Comment 7 Marcel Wiesweg 2011-07-11 17:03:05 UTC
Git commit ff2903be03be371a2d3eff365a9c197b44f836c7 by Marcel Wiesweg.
Committed on 01/07/2011 at 14:16.
Pushed by mwiesweg into branch 'master'.

It makes sense to display the message on the console when an error occurs
and the operation is aborted by longjmp.

BUG: 276154

M  +1    -3    libs/jpegutils/jpegutils.cpp     

http://commits.kde.org/digikam/ff2903be03be371a2d3eff365a9c197b44f836c7