[Digikam-devel] [Bug 121370] Can't save images sometimes after some modifications
Marcel Wiesweg
marcel.wiesweg at gmx.de
Thu Feb 9 20:03:41 GMT 2006
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
http://bugs.kde.org/show_bug.cgi?id=121370
------- Additional Comments From marcel.wiesweg gmx de 2006-02-09 21:03 -------
SVN commit 507673 by mwiesweg:
First part of the fix for 121370, only curing symptoms
- try harder finding a mimetype in DImgInterface
- remove const char usage, use QString (not part of the fix)
CCBUG: 121370
M +7 -5 libs/dimg/dimg.cpp
M +1 -1 libs/dimg/dimg.h
M +1 -1 libs/threadimageio/loadsavetask.cpp
M +16 -6 utilities/imageeditor/canvas/dimginterface.cpp
--- trunk/extragear/graphics/digikam/libs/dimg/dimg.cpp #507672:507673
@ -238,14 +238,16 @
return false;
}
-bool DImg::save(const QString& filePath, const char* format, DImgLoaderObserver *observer)
+bool DImg::save(const QString& filePath, const QString& format, DImgLoaderObserver *observer)
{
if (isNull())
return false;
-
- QString frm = QString::fromLatin1(format);
- frm = frm.upper();
-
+
+ if (format.isEmpty())
+ return false;
+
+ QString frm = format.upper();
+
if (frm == "JPEG" || frm == "JPG")
{
JPEGLoader loader(this);
--- trunk/extragear/graphics/digikam/libs/dimg/dimg.h #507672:507673
@ -109,7 +109,7 @
bool load(const QString& filePath, DImgLoaderObserver *observer = 0,
RawDecodingSettings rawDecodingSettings=RawDecodingSettings());
- bool save(const QString& filePath, const char* format, DImgLoaderObserver *observer = 0);
+ bool save(const QString& filePath, const QString& format, DImgLoaderObserver *observer = 0);
bool isNull() const;
uint width() const;
--- trunk/extragear/graphics/digikam/libs/threadimageio/loadsavetask.cpp #507672:507673
@ -325,7 +325,7 @
void SavingTask::execute()
{
- bool success = m_img.save(m_filePath, m_format.ascii(), this);
+ bool success = m_img.save(m_filePath, m_format, this);
m_thread->taskHasFinished();
QApplication::postEvent(m_thread, new SavedEvent(m_filePath, success));
};
--- trunk/extragear/graphics/digikam/utilities/imageeditor/canvas/dimginterface.cpp #507672:507673
@ -433,7 +433,7 @
}
void DImgInterface::saveAs(const QString& file, IOFileSettingsContainer *iofileSettings,
- const QString& mimeType)
+ const QString& givenMimeType)
{
d->cmod.reset();
d->cmod.setGamma(d->gamma);
@ -443,17 +443,27 @
d->needClearUndoManager = false;
+ // Try hard to find a mimetype.
+ QString mimeType = givenMimeType;
+ // This is possibly empty
if (mimeType.isEmpty())
- saveAction(file, iofileSettings, d->image.attribute("format").toString());
- else
- saveAction(file, iofileSettings, mimeType);
+ {
+ mimeType = d->image.attribute("format").toString();
+ // It is a bug if format attribute is not given
+ if (mimeType.isEmpty())
+ {
+ kdWarning() << "DImg object does not contain attribute \"format\"" << endl;
+ mimeType = QImageIO::imageFormat(d->filename);
+ }
+ }
+ saveAction(file, iofileSettings, mimeType);
}
void DImgInterface::saveAction(const QString& fileName, IOFileSettingsContainer *iofileSettings,
const QString& mimeType)
{
kdDebug() << "Saving to :" << QFile::encodeName(fileName).data() << " ("
- << mimeType.ascii() << ")" << endl;
+ << mimeType << ")" << endl;
if ( mimeType.upper() == QString("JPG") || mimeType.upper() == QString("JPEG") )
d->image.setAttribute("quality", iofileSettings->JPEGCompression);
@ -465,7 +475,7 @
d->image.setAttribute("compress", iofileSettings->TIFFCompression);
d->savingFilename = fileName;
- d->thread->save(d->image, fileName, mimeType.ascii());
+ d->thread->save(d->image, fileName, mimeType);
}
void DImgInterface::slotImageSaved(const QString& filePath, bool success)
More information about the Digikam-devel
mailing list