r18203 by fschmid - Fixed Bug 11116 by changing the way inline images are handled.
scribus-commit
scribus-commit at lists.scribus.net
Tue Mar 12 21:13:04 UTC 2013
Author: fschmid
Date: Tue Mar 12 21:13:04 2013
New Revision: 18203
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=18203
Log:
Fixed Bug 11116 by changing the way inline images are handled.
Modified:
trunk/Scribus/scribus/pageitem.cpp
trunk/Scribus/scribus/pageitem.h
trunk/Scribus/scribus/pageitem_imageframe.cpp
trunk/Scribus/scribus/pageitem_osgframe.cpp
trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp
trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
trunk/Scribus/scribus/plugins/import/ai/importai.cpp
trunk/Scribus/scribus/plugins/import/cgm/importcgm.cpp
trunk/Scribus/scribus/plugins/import/drw/importdrw.cpp
trunk/Scribus/scribus/plugins/import/idml/importidml.cpp
trunk/Scribus/scribus/plugins/import/pct/importpct.cpp
trunk/Scribus/scribus/plugins/import/pdf/slaoutput.cpp
trunk/Scribus/scribus/plugins/import/svg/svgplugin.cpp
trunk/Scribus/scribus/plugins/import/wpg/importwpg.cpp
trunk/Scribus/scribus/plugins/import/xar/importxar.cpp
trunk/Scribus/scribus/scribus.cpp
trunk/Scribus/scribus/scribusdoc.cpp
Modified: trunk/Scribus/scribus/pageitem.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18203&path=/trunk/Scribus/scribus/pageitem.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem.cpp (original)
+++ trunk/Scribus/scribus/pageitem.cpp Tue Mar 12 21:13:04 2013
@@ -347,18 +347,21 @@
{
QFileInfo inlFi(Pfile);
QString ext = inlFi.suffix();
- tempImageFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_XXXXXX." + ext);
- tempImageFile->open();
- QString fileName = getLongPathName(tempImageFile->fileName());
- tempImageFile->close();
+ QTemporaryFile *tempFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_XXXXXX." + ext);
+ tempFile->setAutoRemove(false);
+ tempFile->open();
+ QString fileName = getLongPathName(tempFile->fileName());
+ tempFile->close();
copyFile(Pfile, fileName);
Pfile = fileName;
+ delete tempFile;
isInlineImage = true;
- }
- else
- {
- tempImageFile = NULL;
+ isTempFile = true;
+ }
+ else
+ {
isInlineImage = false;
+ isTempFile = false;
}
Parent = NULL;
unWeld();
@@ -822,14 +825,14 @@
)
pageItemAttributes.append(*objAttrIt);
}
- tempImageFile = NULL;
isInlineImage = false;
+ isTempFile = false;
}
PageItem::~PageItem()
{
- if (tempImageFile != NULL)
- delete tempImageFile;
+ if ((isTempFile) && (!Pfile.isEmpty()))
+ QFile::remove(Pfile);
//remove marks
if (isTextFrame())
@@ -10220,10 +10223,11 @@
inlineImageData.append(data);
if (inlineImageData.size() > 0)
{
- tempImageFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_XXXXXX." + inlineExt);
- tempImageFile->open();
- QString fileName = getLongPathName(tempImageFile->fileName());
- tempImageFile->close();
+ QTemporaryFile *tempFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_XXXXXX." + inlineExt);
+ tempFile->setAutoRemove(false);
+ tempFile->open();
+ QString fileName = getLongPathName(tempFile->fileName());
+ tempFile->close();
inlineImageData = qUncompress(QByteArray::fromBase64(inlineImageData));
QFile outFil(fileName);
if (outFil.open(QIODevice::WriteOnly))
@@ -10231,7 +10235,9 @@
outFil.write(inlineImageData);
outFil.close();
isInlineImage = true;
+ isTempFile = true;
Pfile = fileName;
+ delete tempFile;
}
}
}
@@ -10240,24 +10246,28 @@
{
QFileInfo fi(Pfile);
QString ext = fi.suffix();
- tempImageFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_XXXXXX." + ext);
- tempImageFile->open();
- QString fileName = getLongPathName(tempImageFile->fileName());
- tempImageFile->close();
+ QTemporaryFile *tempFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_XXXXXX." + ext);
+ tempFile->setAutoRemove(false);
+ tempFile->open();
+ QString fileName = getLongPathName(tempFile->fileName());
+ tempFile->close();
isInlineImage = true;
+ isTempFile = true;
copyFile(Pfile, fileName);
Pfile = fileName;
+ delete tempFile;
}
void PageItem::makeImageExternal(QString path)
{
- if ((tempImageFile) && (isInlineImage) && (!path.isEmpty()))
- {
+ if ((isTempFile) && (isInlineImage) && (!path.isEmpty()))
+ {
+ QString oldF = Pfile;
copyFile(Pfile, path);
Pfile = path;
+ QFile::remove(oldF);
isInlineImage = false;
- delete tempImageFile;
- tempImageFile = NULL;
+ isTempFile = false;
}
}
Modified: trunk/Scribus/scribus/pageitem.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18203&path=/trunk/Scribus/scribus/pageitem.h
==============================================================================
--- trunk/Scribus/scribus/pageitem.h (original)
+++ trunk/Scribus/scribus/pageitem.h Tue Mar 12 21:13:04 2013
@@ -1378,7 +1378,7 @@
/** Inline Image */
bool isInlineImage;
- QTemporaryFile *tempImageFile;
+ bool isTempFile;
//items welding (item follows while item moves which they are connected with)
struct weldingInfo
{
Modified: trunk/Scribus/scribus/pageitem_imageframe.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18203&path=/trunk/Scribus/scribus/pageitem_imageframe.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem_imageframe.cpp (original)
+++ trunk/Scribus/scribus/pageitem_imageframe.cpp Tue Mar 12 21:13:04 2013
@@ -246,9 +246,9 @@
setFillTransparency(0.0);
setLineTransparency(0.0);
imageClip.resize(0);
- if (tempImageFile != NULL)
- delete tempImageFile;
- tempImageFile = NULL;
+ if ((isTempFile) && (!Pfile.isEmpty()))
+ QFile::remove(Pfile);
+ isTempFile = false;
isInlineImage = false;
// emit UpdtObj(Doc->currentPage->pageNr(), ItemNr);
}
Modified: trunk/Scribus/scribus/pageitem_osgframe.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18203&path=/trunk/Scribus/scribus/pageitem_osgframe.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem_osgframe.cpp (original)
+++ trunk/Scribus/scribus/pageitem_osgframe.cpp Tue Mar 12 21:13:04 2013
@@ -108,12 +108,15 @@
}
else
{
- tempImageFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_osg_XXXXXX.png");
- tempImageFile->open();
- QString imgName = getLongPathName(tempImageFile->fileName());
- tempImageFile->close();
+ QTemporaryFile *tempFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_osg_XXXXXX.png");
+ tempFile->setAutoRemove(false);
+ tempFile->open();
+ QString imgName = getLongPathName(tempFile->fileName());
+ tempFile->close();
image.save(imgName, "PNG");
m_Doc->loadPict(imgName, this);
+ delete tempFile;
+ isTempFile = true;
}
setImageScalingMode(false, true);
}
Modified: trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18203&path=/trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp (original)
+++ trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp Tue Mar 12 21:13:04 2013
@@ -2499,10 +2499,11 @@
{
if (inlineImageData.size() > 0)
{
- currItem->tempImageFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_XXXXXX." + inlineImageExt);
- currItem->tempImageFile->open();
- QString fileName = getLongPathName(currItem->tempImageFile->fileName());
- currItem->tempImageFile->close();
+ QTemporaryFile *tempFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_XXXXXX." + inlineImageExt);
+ tempFile->setAutoRemove(false);
+ tempFile->open();
+ QString fileName = getLongPathName(tempFile->fileName());
+ tempFile->close();
inlineImageData = qUncompress(QByteArray::fromBase64(inlineImageData));
QFile outFil(fileName);
if (outFil.open(QIODevice::WriteOnly))
@@ -2511,7 +2512,9 @@
outFil.close();
currItem->isInlineImage = true;
currItem->Pfile = fileName;
+ currItem->isTempFile = true;
}
+ delete tempFile;
}
}
else
Modified: trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18203&path=/trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp (original)
+++ trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp Tue Mar 12 21:13:04 2013
@@ -4440,10 +4440,11 @@
{
if (inlineImageData.size() > 0)
{
- currItem->tempImageFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_XXXXXX." + inlineImageExt);
- currItem->tempImageFile->open();
- QString fileName = getLongPathName(currItem->tempImageFile->fileName());
- currItem->tempImageFile->close();
+ QTemporaryFile *tempFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_XXXXXX." + inlineImageExt);
+ tempFile->setAutoRemove(false);
+ tempFile->open();
+ QString fileName = getLongPathName(tempFile->fileName());
+ tempFile->close();
inlineImageData = qUncompress(QByteArray::fromBase64(inlineImageData));
QFile outFil(fileName);
if (outFil.open(QIODevice::WriteOnly))
@@ -4452,7 +4453,9 @@
outFil.close();
currItem->isInlineImage = true;
currItem->Pfile = fileName;
+ currItem->isTempFile = true;
}
+ delete tempFile;
}
}
else
Modified: trunk/Scribus/scribus/plugins/import/ai/importai.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18203&path=/trunk/Scribus/scribus/plugins/import/ai/importai.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/ai/importai.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/ai/importai.cpp Tue Mar 12 21:13:04 2013
@@ -1445,13 +1445,16 @@
ite->setWidthHeight(wh.x(),wh.y());
ite->setTextFlowMode(PageItem::TextFlowDisabled);
m_Doc->AdjustItemSize(ite);
- ite->tempImageFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_ai_XXXXXX.pdf");
- ite->tempImageFile->open();
- ite->tempImageFile->write(fData);
- QString imgName = getLongPathName(ite->tempImageFile->fileName());
- ite->tempImageFile->close();
+ QTemporaryFile *tempFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_ai_XXXXXX.pdf");
+ tempFile->setAutoRemove(false);
+ tempFile->open();
+ tempFile->write(fData);
+ QString imgName = getLongPathName(tempFile->fileName());
+ tempFile->close();
ite->isInlineImage = true;
+ ite->isTempFile = true;
m_Doc->loadPict(imgName, ite);
+ delete tempFile;
if (ite->PictureIsAvailable)
ite->setImageXYScale(ite->width() / ite->pixm.width(), ite->height() / ite->pixm.height());
ite->setImageFlippedV(true);
@@ -3048,11 +3051,14 @@
uchar *p;
uint yCount = 0;
quint16 eTag = EXTRASAMPLE_UNASSALPHA;
- ite->tempImageFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_ai_XXXXXX.tif");
- ite->tempImageFile->open();
- QString imgName = getLongPathName(ite->tempImageFile->fileName());
- ite->tempImageFile->close();
+ QTemporaryFile *tempFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_ai_XXXXXX.tif");
+ tempFile->setAutoRemove(false);
+ tempFile->open();
+ QString imgName = getLongPathName(tempFile->fileName());
+ tempFile->close();
ite->isInlineImage = true;
+ ite->isTempFile = true;
+ delete tempFile;
TIFF* tif = TIFFOpen(imgName.toLocal8Bit().data(), "w");
if (tif)
{
Modified: trunk/Scribus/scribus/plugins/import/cgm/importcgm.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18203&path=/trunk/Scribus/scribus/plugins/import/cgm/importcgm.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/cgm/importcgm.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/cgm/importcgm.cpp Tue Mar 12 21:13:04 2013
@@ -1562,15 +1562,18 @@
istr.skipRawData(1);
}
}
- ite->tempImageFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_cgm_XXXXXX.png");
- ite->tempImageFile->open();
- QString fileName = getLongPathName(ite->tempImageFile->fileName());
- ite->tempImageFile->close();
+ QTemporaryFile *tempFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_cgm_XXXXXX.png");
+ tempFile->setAutoRemove(false);
+ tempFile->open();
+ QString fileName = getLongPathName(tempFile->fileName());
+ tempFile->close();
ite->isInlineImage = true;
+ ite->isTempFile = true;
image.save(fileName, "PNG");
if ((image.width() < 20) || image.height() < 20)
ite->pixm.imgInfo.lowResType = 0;
m_Doc->loadPict(fileName, ite);
+ delete tempFile;
ite->setImageFlippedH(flipX);
ite->setImageFlippedV(flipY);
ite->setImageScalingMode(false, false);
@@ -2392,14 +2395,16 @@
m_Doc->AdjustItemSize(ite);
ite->OldB2 = ite->width();
ite->OldH2 = ite->height();
- ite->tempImageFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_cgm_XXXXXX.png");
- if (ite->tempImageFile->open())
- {
- QString fileName = getLongPathName(ite->tempImageFile->fileName());
+ QTemporaryFile *tempFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_cgm_XXXXXX.png");
+ tempFile->setAutoRemove(false);
+ if (tempFile->open())
+ {
+ QString fileName = getLongPathName(tempFile->fileName());
if (!fileName.isEmpty())
{
- ite->tempImageFile->close();
+ tempFile->close();
ite->isInlineImage = true;
+ ite->isTempFile = true;
tmpImg.save(fileName, "PNG");
m_Doc->loadPict(fileName, ite);
ite->setImageScalingMode(false, true);
@@ -2430,6 +2435,7 @@
m_Doc->Items->removeAll(ite);
delete ite;
}
+ delete tempFile;
colorPrecision = t_colorPrecision;
// qDebug() << "PATTERN TABLE" << "Index" << index << "NX" << nx << "NY" << ny;
}
Modified: trunk/Scribus/scribus/plugins/import/drw/importdrw.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18203&path=/trunk/Scribus/scribus/plugins/import/drw/importdrw.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/drw/importdrw.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/drw/importdrw.cpp Tue Mar 12 21:13:04 2013
@@ -904,13 +904,16 @@
{
if (currentItem != NULL)
{
- currentItem->tempImageFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_drw_XXXXXX.png");
- currentItem->tempImageFile->open();
- QString fileName = getLongPathName(currentItem->tempImageFile->fileName());
- currentItem->tempImageFile->close();
+ QTemporaryFile *tempFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_drw_XXXXXX.png");
+ tempFile->setAutoRemove(false);
+ tempFile->open();
+ QString fileName = getLongPathName(tempFile->fileName());
+ tempFile->close();
currentItem->isInlineImage = true;
+ currentItem->isTempFile = true;
tmpImage.save(fileName, "PNG");
m_Doc->loadPict(fileName, currentItem);
+ delete tempFile;
currentItem->setImageScalingMode(false, false);
}
imageValid = false;
@@ -965,7 +968,7 @@
{
if (currentItem->asImageFrame())
{
- QString fileName = getLongPathName(currentItem->tempImageFile->fileName());
+ QString fileName = currentItem->Pfile;
if (!fileName.isEmpty())
{
QVector<QRgb> colors;
@@ -1873,11 +1876,14 @@
ScPattern pat = ScPattern();
pat.setDoc(m_Doc);
PageItem* newItem = new PageItem_ImageFrame(m_Doc, 0, 0, 1, 1, 0, CommonStrings::None, CommonStrings::None);
- newItem->tempImageFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_drw_XXXXXX.png");
- newItem->tempImageFile->open();
- QString fileName = getLongPathName(newItem->tempImageFile->fileName());
- newItem->tempImageFile->close();
+ QTemporaryFile *tempFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_drw_XXXXXX.png");
+ tempFile->setAutoRemove(false);
+ tempFile->open();
+ QString fileName = getLongPathName(tempFile->fileName());
+ tempFile->close();
+ delete tempFile;
newItem->isInlineImage = true;
+ newItem->isTempFile = true;
image.setDotsPerMeterY(2834);
image.setDotsPerMeterX(2834);
image.save(fileName, "PNG");
Modified: trunk/Scribus/scribus/plugins/import/idml/importidml.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18203&path=/trunk/Scribus/scribus/plugins/import/idml/importidml.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/idml/importidml.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/idml/importidml.cpp Tue Mar 12 21:13:04 2013
@@ -2279,15 +2279,17 @@
imgExt = "psd";
else if (imageType.contains("TIFF", Qt::CaseInsensitive))
imgExt = "tif";
- item->tempImageFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_idml_XXXXXX." + imgExt);
- if (item->tempImageFile->open())
- {
- QString fileName = getLongPathName(item->tempImageFile->fileName());
+ QTemporaryFile *tempFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_idml_XXXXXX." + imgExt);
+ tempFile->setAutoRemove(false);
+ if (tempFile->open())
+ {
+ QString fileName = getLongPathName(tempFile->fileName());
if (!fileName.isEmpty())
{
- item->tempImageFile->write(imageData);
- item->tempImageFile->close();
+ tempFile->write(imageData);
+ tempFile->close();
item->isInlineImage = true;
+ item->isTempFile = true;
item->ScaleType = true;
item->AspectRatio = true;
m_Doc->loadPict(fileName, item);
@@ -2296,6 +2298,7 @@
item->setImageRotation(-roti);
}
}
+ delete tempFile;
}
else
{
Modified: trunk/Scribus/scribus/plugins/import/pct/importpct.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18203&path=/trunk/Scribus/scribus/plugins/import/pct/importpct.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/pct/importpct.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/pct/importpct.cpp Tue Mar 12 21:13:04 2013
@@ -1010,17 +1010,20 @@
image = image.convertToFormat(QImage::Format_ARGB32);
int z = m_Doc->itemAdd(PageItem::ImageFrame, PageItem::Unspecified, baseX, baseY, image.width() * resX, image.height() * resY, 0, m_Doc->itemToolPrefs().imageFillColor, CommonStrings::None, true);
PageItem *ite = m_Doc->Items->at(z);
- ite->tempImageFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_pct_XXXXXX.png");
- ite->tempImageFile->open();
- QString fileName = getLongPathName(ite->tempImageFile->fileName());
- ite->tempImageFile->close();
+ QTemporaryFile *tempFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_pct_XXXXXX.png");
+ tempFile->setAutoRemove(false);
+ tempFile->open();
+ QString fileName = getLongPathName(tempFile->fileName());
+ tempFile->close();
ite->isInlineImage = true;
+ ite->isTempFile = true;
image.save(fileName, "PNG");
ite->moveBy(m_Doc->currentPage()->xOffset(), m_Doc->currentPage()->yOffset());
ite->moveBy(offsetX, offsetY);
finishItem(ite);
m_Doc->loadPict(fileName, ite);
ite->setImageScalingMode(false, false);
+ delete tempFile;
}
// qDebug() << "End of Pict";
return;
@@ -1846,11 +1849,14 @@
image.invertPixels();
int z = m_Doc->itemAdd(PageItem::ImageFrame, PageItem::Unspecified, baseX + dstRect.left() * resX, baseY + dstRect.top() * resY, imgCols * resY, imgRows * resY, 0, m_Doc->itemToolPrefs().imageFillColor, m_Doc->itemToolPrefs().imageStrokeColor, true);
PageItem *ite = m_Doc->Items->at(z);
- ite->tempImageFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_pct_XXXXXX.png");
- ite->tempImageFile->open();
- QString fileName = getLongPathName(ite->tempImageFile->fileName());
- ite->tempImageFile->close();
+ QTemporaryFile *tempFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_pct_XXXXXX.png");
+ tempFile->setAutoRemove(false);
+ tempFile->open();
+ QString fileName = getLongPathName(tempFile->fileName());
+ tempFile->close();
+ delete tempFile;
ite->isInlineImage = true;
+ ite->isTempFile = true;
image.save(fileName, "PNG");
ite->moveBy(baseX, baseY);
ite->moveBy(offsetX, offsetY);
@@ -2184,11 +2190,14 @@
ScPattern pat = ScPattern();
pat.setDoc(m_Doc);
PageItem* newItem = new PageItem_ImageFrame(m_Doc, 0, 0, 1, 1, 0, CommonStrings::None, CommonStrings::None);
- newItem->tempImageFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_pct_XXXXXX.png");
- newItem->tempImageFile->open();
- QString fileName = getLongPathName(newItem->tempImageFile->fileName());
- newItem->tempImageFile->close();
+ QTemporaryFile *tempFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_pct_XXXXXX.png");
+ tempFile->setAutoRemove(false);
+ tempFile->open();
+ QString fileName = getLongPathName(tempFile->fileName());
+ tempFile->close();
+ delete tempFile;
newItem->isInlineImage = true;
+ newItem->isTempFile = true;
image.setDotsPerMeterY(2834);
image.setDotsPerMeterX(2834);
image.save(fileName, "PNG");
Modified: trunk/Scribus/scribus/plugins/import/pdf/slaoutput.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18203&path=/trunk/Scribus/scribus/plugins/import/pdf/slaoutput.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/pdf/slaoutput.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/pdf/slaoutput.cpp Tue Mar 12 21:13:04 2013
@@ -2412,14 +2412,16 @@
ite->setFillShade(100);
ite->setLineShade(100);
ite->setFillEvenOdd(false);
- ite->tempImageFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_pdf_XXXXXX.png");
- if (ite->tempImageFile->open())
- {
- QString fileName = getLongPathName(ite->tempImageFile->fileName());
+ QTemporaryFile *tempFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_pdf_XXXXXX.png");
+ tempFile->setAutoRemove(false);
+ if (tempFile->open())
+ {
+ QString fileName = getLongPathName(tempFile->fileName());
if (!fileName.isEmpty())
{
- ite->tempImageFile->close();
+ tempFile->close();
ite->isInlineImage = true;
+ ite->isTempFile = true;
res.save(fileName, "PNG");
m_doc->loadPict(fileName, ite);
ite->setImageScalingMode(false, true);
@@ -2437,6 +2439,7 @@
else
m_doc->Items->removeAll(ite);
imgStr->close();
+ delete tempFile;
delete imgStr;
delete image;
}
@@ -2536,14 +2539,16 @@
ite->setFillEvenOdd(false);
ite->setFillTransparency(1.0 - state->getFillOpacity());
ite->setFillBlendmode(getBlendMode(state));
- ite->tempImageFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_pdf_XXXXXX.png");
- if (ite->tempImageFile->open())
- {
- QString fileName = getLongPathName(ite->tempImageFile->fileName());
+ QTemporaryFile *tempFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_pdf_XXXXXX.png");
+ tempFile->setAutoRemove(false);
+ if (tempFile->open())
+ {
+ QString fileName = getLongPathName(tempFile->fileName());
if (!fileName.isEmpty())
{
- ite->tempImageFile->close();
+ tempFile->close();
ite->isInlineImage = true;
+ ite->isTempFile = true;
res.save(fileName, "PNG");
m_doc->loadPict(fileName, ite);
ite->setImageScalingMode(false, true);
@@ -2560,6 +2565,7 @@
}
else
m_doc->Items->removeAll(ite);
+ delete tempFile;
delete imgStr;
delete[] buffer;
delete image;
@@ -2651,14 +2657,16 @@
ite->setFillEvenOdd(false);
ite->setFillTransparency(1.0 - state->getFillOpacity());
ite->setFillBlendmode(getBlendMode(state));
- ite->tempImageFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_pdf_XXXXXX.png");
- if (ite->tempImageFile->open())
- {
- QString fileName = getLongPathName(ite->tempImageFile->fileName());
+ QTemporaryFile *tempFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_pdf_XXXXXX.png");
+ tempFile->setAutoRemove(false);
+ if (tempFile->open())
+ {
+ QString fileName = getLongPathName(tempFile->fileName());
if (!fileName.isEmpty())
{
- ite->tempImageFile->close();
+ tempFile->close();
ite->isInlineImage = true;
+ ite->isTempFile = true;
img.save(fileName, "PNG");
m_doc->loadPict(fileName, ite);
ite->setImageScalingMode(false, true);
@@ -2675,6 +2683,7 @@
}
else
m_doc->Items->removeAll(ite);
+ delete tempFile;
delete imgStr;
delete[] buffer;
delete image;
Modified: trunk/Scribus/scribus/plugins/import/svg/svgplugin.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18203&path=/trunk/Scribus/scribus/plugins/import/svg/svgplugin.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/svg/svgplugin.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/svg/svgplugin.cpp Tue Mar 12 21:13:04 2013
@@ -1530,10 +1530,13 @@
ba.append(fname);
if (dataType.contains("base64"))
ba = QByteArray::fromBase64(ba);
- ite->tempImageFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_svg_XXXXXX.png");
- ite->tempImageFile->open();
- QString fileName = getLongPathName(ite->tempImageFile->fileName());
- ite->tempImageFile->close();
+ QTemporaryFile *tempFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_svg_XXXXXX.png");
+ tempFile->setAutoRemove(false);
+ tempFile->open();
+ QString fileName = getLongPathName(tempFile->fileName());
+ tempFile->close();
+ delete tempFile;
+ ite->isTempFile = true;
ite->isInlineImage = true;
QImage img;
img.loadFromData(ba);
Modified: trunk/Scribus/scribus/plugins/import/wpg/importwpg.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18203&path=/trunk/Scribus/scribus/plugins/import/wpg/importwpg.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/wpg/importwpg.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/wpg/importwpg.cpp Tue Mar 12 21:13:04 2013
@@ -395,10 +395,13 @@
double h = (bitmap.rect.y2 - bitmap.rect.y1) * 72.0;
int z = m_Doc->itemAdd(PageItem::ImageFrame, PageItem::Unspecified, bitmap.rect.x1 * 72 + baseX, bitmap.rect.y1 * 72 + baseY, w, h, 1, m_Doc->itemToolPrefs().imageFillColor, m_Doc->itemToolPrefs().imageStrokeColor, true);
PageItem *ite = m_Doc->Items->at(z);
- ite->tempImageFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_wpg_XXXXXX.png");
- ite->tempImageFile->open();
- QString fileName = getLongPathName(ite->tempImageFile->fileName());
- ite->tempImageFile->close();
+ QTemporaryFile *tempFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_wpg_XXXXXX.png");
+ tempFile->setAutoRemove(false);
+ tempFile->open();
+ QString fileName = getLongPathName(tempFile->fileName());
+ tempFile->close();
+ delete tempFile;
+ ite->isTempFile = true;
ite->isInlineImage = true;
image.setDotsPerMeterX ((int) (hres / 0.0254));
image.setDotsPerMeterY ((int) (vres / 0.0254));
Modified: trunk/Scribus/scribus/plugins/import/xar/importxar.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18203&path=/trunk/Scribus/scribus/plugins/import/xar/importxar.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/xar/importxar.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/xar/importxar.cpp Tue Mar 12 21:13:04 2013
@@ -1834,10 +1834,13 @@
ScPattern pat = ScPattern();
pat.setDoc(m_Doc);
PageItem* newItem = new PageItem_ImageFrame(m_Doc, 0, 0, 1, 1, 0, CommonStrings::None, CommonStrings::None);
- newItem->tempImageFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_xar_XXXXXX.png");
- newItem->tempImageFile->open();
- QString fileName = getLongPathName(newItem->tempImageFile->fileName());
- newItem->tempImageFile->close();
+ QTemporaryFile *tempFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_xar_XXXXXX.png");
+ tempFile->setAutoRemove(false);
+ tempFile->open();
+ QString fileName = getLongPathName(tempFile->fileName());
+ tempFile->close();
+ delete tempFile;
+ newItem->isTempFile = true;
newItem->isInlineImage = true;
image.setDotsPerMeterY(2834);
image.setDotsPerMeterX(2834);
@@ -2597,10 +2600,13 @@
ScPattern pat = ScPattern();
pat.setDoc(m_Doc);
PageItem* newItem = new PageItem_ImageFrame(m_Doc, 0, 0, 1, 1, 0, CommonStrings::None, CommonStrings::None);
- newItem->tempImageFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_xar_XXXXXX.png");
- newItem->tempImageFile->open();
- QString fileName = getLongPathName(newItem->tempImageFile->fileName());
- newItem->tempImageFile->close();
+ QTemporaryFile *tempFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_xar_XXXXXX.png");
+ tempFile->setAutoRemove(false);
+ tempFile->open();
+ QString fileName = getLongPathName(tempFile->fileName());
+ tempFile->close();
+ delete tempFile;
+ newItem->isTempFile = true;
newItem->isInlineImage = true;
image.setDotsPerMeterY(2834);
image.setDotsPerMeterX(2834);
@@ -2684,10 +2690,13 @@
QString imgNam = m_Doc->docPatterns[patternRef[bref]].items.at(0)->externalFile();
QImage image;
image.load(imgNam);
- ite->tempImageFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_xar_XXXXXX.png");
- ite->tempImageFile->open();
- QString fileName = getLongPathName(ite->tempImageFile->fileName());
- ite->tempImageFile->close();
+ QTemporaryFile *tempFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_xar_XXXXXX.png");
+ tempFile->setAutoRemove(false);
+ tempFile->open();
+ QString fileName = getLongPathName(tempFile->fileName());
+ tempFile->close();
+ delete tempFile;
+ ite->isTempFile = true;
ite->isInlineImage = true;
image.save(fileName, "PNG");
m_Doc->loadPict(fileName, ite);
@@ -2748,10 +2757,13 @@
ScPattern pat = ScPattern();
pat.setDoc(m_Doc);
PageItem* newItem = new PageItem_ImageFrame(m_Doc, 0, 0, 1, 1, 0, CommonStrings::None, CommonStrings::None);
- newItem->tempImageFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_xar_XXXXXX.png");
- newItem->tempImageFile->open();
- QString fileName = getLongPathName(newItem->tempImageFile->fileName());
- newItem->tempImageFile->close();
+ QTemporaryFile *tempFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_xar_XXXXXX.png");
+ tempFile->setAutoRemove(false);
+ tempFile->open();
+ QString fileName = getLongPathName(tempFile->fileName());
+ tempFile->close();
+ delete tempFile;
+ newItem->isTempFile = true;
newItem->isInlineImage = true;
image.setDotsPerMeterY(2834);
image.setDotsPerMeterX(2834);
Modified: trunk/Scribus/scribus/scribus.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18203&path=/trunk/Scribus/scribus/scribus.cpp
==============================================================================
--- trunk/Scribus/scribus/scribus.cpp (original)
+++ trunk/Scribus/scribus/scribus.cpp Tue Mar 12 21:13:04 2013
@@ -4482,11 +4482,14 @@
currItem->IRender = doc->cmsSettings().DefaultIntentImages;
qApp->setOverrideCursor( QCursor(Qt::WaitCursor) );
qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
- currItem->tempImageFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_XXXXXX.png");
- currItem->tempImageFile->open();
- QString fileName = getLongPathName(currItem->tempImageFile->fileName());
- currItem->tempImageFile->close();
+ QTemporaryFile *tempFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_XXXXXX.png");
+ tempFile->setAutoRemove(false);
+ tempFile->open();
+ QString fileName = getLongPathName(tempFile->fileName());
+ tempFile->close();
+ delete tempFile;
currItem->isInlineImage = true;
+ currItem->isTempFile = true;
currItem->Pfile = fileName;
img.save(fileName, "PNG");
doc->loadPict(fileName, currItem, false, true);
Modified: trunk/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18203&path=/trunk/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.cpp (original)
+++ trunk/Scribus/scribus/scribusdoc.cpp Tue Mar 12 21:13:04 2013
@@ -5796,10 +5796,10 @@
if ((ScCore->fileWatcher->files().contains(pageItem->Pfile) != 0) && (pageItem->PictureIsAvailable))
{
ScCore->fileWatcher->removeFile(pageItem->Pfile);
- if (pageItem->tempImageFile != NULL)
- delete pageItem->tempImageFile;
- pageItem->tempImageFile = NULL;
+ QFile::remove(pageItem->Pfile);
+ pageItem->Pfile = "";
pageItem->isInlineImage = false;
+ pageItem->isTempFile = false;
}
}
if(!pageItem->loadImage(fn, reload, -1, showMsg))
More information about the scribus-commit
mailing list