Exiv2 error handling implemented. Now it doesn't crash when there's a gif
This commit is contained in:
parent
5e400c5d51
commit
fdfdffc9b0
10
picture.cpp
10
picture.cpp
@ -3,6 +3,7 @@
|
||||
#include <QDragEnterEvent>
|
||||
#include <QMimeData>
|
||||
#include <QRegExp>
|
||||
#include <QMessageBox>
|
||||
Picture::Picture(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::Picture){
|
||||
@ -31,7 +32,6 @@ void Picture::dropEvent(QDropEvent *event){
|
||||
//qDebug() << "Dropped file:" << fileName;
|
||||
}
|
||||
}
|
||||
|
||||
void Picture::changeDirectory(){
|
||||
QString path=QFileDialog::getExistingDirectory(this,tr("Directory"),directory.path());
|
||||
if(path.isNull()==false){
|
||||
@ -69,12 +69,20 @@ void Picture::on_erase_clicked(){
|
||||
QImageReader reader(str);
|
||||
if(!reader.format().isEmpty()){
|
||||
QString fullPath=str;
|
||||
try{
|
||||
Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(fullPath.toStdString());
|
||||
assert (image.get() != 0);
|
||||
image->readMetadata();
|
||||
Exiv2::ExifData &exifData = image->exifData();
|
||||
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{
|
||||
if(!ignored){
|
||||
ignored=true;
|
||||
|
@ -41,7 +41,7 @@
|
||||
<item>
|
||||
<widget class="QPushButton" name="cd">
|
||||
<property name="text">
|
||||
<string>Change Directory</string>
|
||||
<string>Open Directory</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
Loading…
Reference in New Issue
Block a user