Exiv2 error handling implemented. Now it doesn't crash when there's a gif
This commit is contained in:
parent
5e400c5d51
commit
fdfdffc9b0
22
picture.cpp
22
picture.cpp
@ -3,6 +3,7 @@
|
|||||||
#include <QDragEnterEvent>
|
#include <QDragEnterEvent>
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
#include <QRegExp>
|
#include <QRegExp>
|
||||||
|
#include <QMessageBox>
|
||||||
Picture::Picture(QWidget *parent) :
|
Picture::Picture(QWidget *parent) :
|
||||||
QMainWindow(parent),
|
QMainWindow(parent),
|
||||||
ui(new Ui::Picture){
|
ui(new Ui::Picture){
|
||||||
@ -31,7 +32,6 @@ void Picture::dropEvent(QDropEvent *event){
|
|||||||
//qDebug() << "Dropped file:" << fileName;
|
//qDebug() << "Dropped file:" << fileName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Picture::changeDirectory(){
|
void Picture::changeDirectory(){
|
||||||
QString path=QFileDialog::getExistingDirectory(this,tr("Directory"),directory.path());
|
QString path=QFileDialog::getExistingDirectory(this,tr("Directory"),directory.path());
|
||||||
if(path.isNull()==false){
|
if(path.isNull()==false){
|
||||||
@ -69,12 +69,20 @@ void Picture::on_erase_clicked(){
|
|||||||
QImageReader reader(str);
|
QImageReader reader(str);
|
||||||
if(!reader.format().isEmpty()){
|
if(!reader.format().isEmpty()){
|
||||||
QString fullPath=str;
|
QString fullPath=str;
|
||||||
Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(fullPath.toStdString());
|
try{
|
||||||
assert (image.get() != 0);
|
Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(fullPath.toStdString());
|
||||||
image->readMetadata();
|
assert (image.get() != 0);
|
||||||
Exiv2::ExifData &exifData = image->exifData();
|
image->readMetadata();
|
||||||
exifData["Exif.Photo.UserComment"] = "charset=Ascii An ASCII Exif comment added with Exiv2";
|
Exiv2::ExifData &exifData = image->exifData();
|
||||||
image->writeMetadata();
|
exifData["Exif.Photo.UserComment"] = "charset=Ascii An ASCII Exif comment added with Exiv2";
|
||||||
|
image->writeMetadata();
|
||||||
|
}catch(Exiv2::AnyError& e){
|
||||||
|
QMessageBox msgBox;
|
||||||
|
msgBox.setInformativeText("The program could not process the file: "+fullPath);
|
||||||
|
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||||
|
msgBox.setDefaultButton(QMessageBox::Ok);
|
||||||
|
int ret=msgBox.exec();
|
||||||
|
}
|
||||||
}else{
|
}else{
|
||||||
if(!ignored){
|
if(!ignored){
|
||||||
ignored=true;
|
ignored=true;
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="cd">
|
<widget class="QPushButton" name="cd">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Change Directory</string>
|
<string>Open Directory</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
Loading…
Reference in New Issue
Block a user