[Digikam-users] potential incompatibility between exiv2-svn and exiv2-0.12

Gilles Caulier caulier.gilles at gmail.com
Thu Mar 15 06:50:46 GMT 2007


Pedro,

I post the Andreas response in this room :

Hi Gilles,

This is due to exiv2 rev. 1077

   http://dev.robotbattle.com/cmtinfo_svn.php?r=10&l=50&v=1077

which changed the signature of Error::what() to return const char*
instead of std::string. The change was necessary to be able to inherit
the Exiv2 errors from std::exception, which is a generally recommended
practice as I learnt recently. There is a thread on this in the Exiv2
group, starting here:

   http://uk.groups.yahoo.com/group/exiv2/message/657

> To fix it, i need to change :
>
>         qDebug("Cannot clear Iptc data using Exiv2 (%s)",
> e.what().c_str());
>
> like
>
>         qDebug("Cannot clear Iptc data using Exiv2 (%s)", e.what());
>
> If i fix the code, likexiv2 will depand of next Exiv2 release only...

There a other possibilities to fix this so that it also compiles with
older versions. I can think of:

1) Use the EXIV2_CHECK_VERSION macro to test which Exiv2 version is in
use

2) Use op<< to build the string, e.g.

       std::ostringstream os;
       os << "Cannot clear Iptc data using Exiv2 (" << e << ")";
       qDebug("%s", os.str().c_str());

3) Make a temporary std::string, e.g.,

       std::string s(e.what());
       qDebug("Cannot clear Iptc data using Exiv2 (%s)", s.c_str());

Regarding 1) I've also added 2 new functions, Exiv2::versionNumber() and
Exiv2::version(), which are used to check the Exiv2 library version
available at _runtime_. In the future you can use these in digikam
about dialog to tell which version the user is running.

Regards,
Andreas

2007/3/14, Gilles Caulier <caulier.gilles at gmail.com>:
>
> Andreas,
>
> look this message from digikam-users mailling list
>
> Any suggestions ?
>
> Gilles
>
> ---------- Forwarded message ----------
> From: Pedro Venda <pjvenda at pjvenda.org>
> Date: 14 mars 2007 23:21
> Subject: [Digikam-users] potential incompatibility between exiv2-svn and
> exiv2-0.12
> To: digikam-users at kde.org
>
> Hi everyone,
>
> I am facing another compilation error, for which I do not have enough C++
> experience to handle. I am compiling digikam along with trunk/exiv2
> and trunk/extragear/libs, I have updated the svn copy of digikam several
> times and even rm -rf and rechecked the whole trees again to rule out any
> mess I might have made.
>
> The following error happens when compiling several objects from
> digikam/libs/widgets/metadata/:
>
> if /bin/sh ../../../../libtool --silent --tag=CXX --mode=compile
> g++ -DHAVE_CONFIG_H -I. -I. -I../../../..
> -I../../../../digikam/libs/dmetadata -I../../../../digikam/libs/dimg
> -I/usr/local/digikam-trunk/include   -I../../../../digikam/digikam
> -I/usr/kde/3.5/include -I/usr/qt/3/include -I.
> -DQT_THREAD_SUPPORT  -D_REENTRANT  -Wno-long-long -Wundef -ansi
> -D_XOPEN_SOURCE=500 -D_BSD_SOURCE -Wcast-align -Wchar-subscripts -Wall -W
> -Wpointer-arith -O2 -I/usr/local/digikam-trunk/include -Wformat-security
> -Wmissing-format-attribute -Wno-non-virtual-dtor -fno-exceptions
> -fno-check-new -fno-common -DQT_CLEAN_NAMESPACE -DQT_NO_ASCII_CAST
> -DQT_NO_STL -DQT_NO_COMPAT -DQT_NO_TRANSLATION -DQT_CLEAN_NAMESPACE
> -DQT_CLEAN_NAMESPACE -DQT_NO_ASCII_CAST -DQT_NO_STL -DQT_NO_COMPAT
> -DQT_NO_TRANSLATION -fexceptions -MT
> iptcwidget.lo -MD -MP -MF ".deps/iptcwidget.Tpo" -c -o iptcwidget.lo
> iptcwidget.cpp; \
>     then mv -f ".deps/iptcwidget.Tpo" ".deps/iptcwidget.Plo"; else
> rm -f ".deps/iptcwidget.Tpo"; exit 1; fi
> iptcwidget.cpp: In member function 'virtual bool
> Digikam::IptcWidget::decodeMetadata()':
> iptcwidget.cpp:159: error: request for member 'c_str'
> in '((Exiv2::Error*)e)->Exiv2::Error::what()', which is of non-class
> type 'const char*'
> iptcwidget.cpp: In member
> function 'virtual QString Digikam::IptcWidget::getTagTitle(const
> QString&)':
> iptcwidget.cpp:188: error: request for member 'c_str'
> in '((Exiv2::Error*)e)->Exiv2::Error::what()', which is of non-class
> type 'const char*'
> iptcwidget.cpp: In member
> function 'virtual QString Digikam::IptcWidget::getTagDescription(const
> QString&)':
> iptcwidget.cpp:205: error: request for member 'c_str'
> in '((Exiv2::Error*)e)->Exiv2::Error::what()', which is of non-class
> type 'const char*'
> make[5]: *** [iptcwidget.lo] Error 1
>
> I looked at the exiv2 error.hpp (exiv2-svn) header and I found that the
> method
> Exiv2::Error.what() already returns a (const char *) so c_str() is
> (probably)
> not adequate. The affected source files were: iptcwidget.cpp,
> exifwidget.cpp,
> gpswidget.cpp and makernotewidget.cpp.
>
> This what() method differs in the way it is being prototyped/implemented
> between exiv2-svn and exiv2-0.12 (error.hpp).
> exiv2-svn is:
>         virtual const char* what() const throw() { return msg_.c_str(); }
> exiv2-0.12 is:
>         virtual std::string what() const;
>
> The call to c_str() might work if called from a std::string object, but
> not
> from a const char * type variable (which is not even semantically
> correct).
> If I remove the call to c_str() on the affected objects, digikam compiles
> correctly but doesn't work. It starts and immediately after showing up the
>
> main screen, it segfaults with:
>
> terminate called after throwing an instance of 'std::bad_alloc'
>   what():  St9bad_alloc
>
> Obviously, this is related to my changes on the source files.
> The next step I took was to compile digikam-svn against my system's
> exiv-0.12.
> It worked well, so I think I have found an incompatibility here...
>
> I need help here from C++ developers. I suppose this should be quite
> simple to
> fix.
>
> Best regards,
> --
>
> Pedro João Lopes Venda
> email: pjvenda at pjvenda org
> http://www.pjvenda.org
> _______________________________________________
> Digikam-users mailing list
> Digikam-users at kde.org
> https://mail.kde.org/mailman/listinfo/digikam-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/digikam-users/attachments/20070315/992e1d98/attachment.html>


More information about the Digikam-users mailing list