Commit a3dbe0f7 authored by Robby Stephenson's avatar Robby Stephenson
Browse files

Use a temporary directory when using a local image directory for new files

When using a local image directory, whose name depends on the Tellico
file name, use a temporary directory until the file is saved the first
time.

BUG: 299130
FIXED-IN: 2.3.6
parent 8054ab9b
2012-05-04 Robby Stephenson <robby@periapsis.org>
* Fixed a bug when using a local image directory for a file that has not yet been saved (Bug 299130).
2012-04-20 Robby Stephenson <robby@periapsis.org>
* Added API data sources for Allocine, ScreenRush, FilmStarts, SensaCine, and Beyazperde.
......
......@@ -40,14 +40,16 @@ using Tellico::ImageDirectory;
using Tellico::TemporaryImageDirectory;
using Tellico::ImageZipArchive;
ImageDirectory::ImageDirectory() : ImageStorage(), m_pathExists(false) {
ImageDirectory::ImageDirectory() : ImageStorage(), m_pathExists(false), m_dir(0) {
}
ImageDirectory::ImageDirectory(const QString& path_) : ImageStorage() {
ImageDirectory::ImageDirectory(const QString& path_) : ImageStorage() , m_dir(0) {
setPath(path_);
}
ImageDirectory::~ImageDirectory() {
delete m_dir;
m_dir = 0;
}
QString ImageDirectory::path() {
......@@ -88,8 +90,12 @@ bool ImageDirectory::writeImage(const Data::Image& img_) {
const QString path = this->path(); // virtual function, so don't assume m_path is correct
if(!m_pathExists) {
if(path.isEmpty()) {
myWarning() << "trying to write to empty path:" << img_.id();
return false;
// an empty path means the file hasn't been saved yet
if(!m_dir) {
m_dir = new KTempDir(); // default is to auto-delete, aka autoRemove()
ImageDirectory::setPath(m_dir->name());
}
return writeImage(img_);
}
QDir dir(path);
if(dir.mkdir(path)) {
......
......@@ -64,6 +64,8 @@ public:
private:
QString m_path;
bool m_pathExists;
// until the file gets saved, the local directory is temporary
KTempDir* m_dir;
};
class TemporaryImageDirectory : public ImageDirectory {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment