Skip to content

Commit

Permalink
Close attachment_iodevice after reading the picture.
Browse files Browse the repository at this point in the history
This is essential to end the transaction opened to fetch
the large object.
  • Loading branch information
manitou-mail committed Oct 30, 2017
1 parent 10bed43 commit 198371f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/attachment.cpp
Expand Up @@ -1061,6 +1061,14 @@ attachment_iodevice::~attachment_iodevice()
{
}

void
attachment_iodevice::close()
{
if (m_a != NULL)
m_a->close(); // ends database transaction
QIODevice::close();
}

qint64
attachment_iodevice::readData(char* data, qint64 size)
{
Expand Down Expand Up @@ -1102,6 +1110,7 @@ attachment_iodevice::isSequential() const
void
attachment_iodevice::abort()
{
if (m_a != NULL)
m_a->close();
}

Expand Down
3 changes: 2 additions & 1 deletion src/attachment.h
Expand Up @@ -186,11 +186,12 @@ class attachment_iodevice: public QIODevice
qint64 readData(char* data, qint64 size);
qint64 writeData(const char* data, qint64 maxsize);
void abort();
void close();
qint64 bytesAvailable() const;
bool atEnd() const;
bool isSequential() const;
private:
attachment* m_a;
attachment* m_a = NULL;
int already_read;
private slots:
void go();
Expand Down
3 changes: 2 additions & 1 deletion src/image_viewer.cpp
Expand Up @@ -70,6 +70,7 @@ image_viewer::show_attachment(attachment* a)
imgr.setAutoTransform(true);
#endif
m_image = imgr.read();
io.close(); // ends transaction

if (m_image.isNull()) {
QMessageBox::critical(this, APP_NAME, tr("Cannot instantiate image from attachment"));
Expand All @@ -88,7 +89,7 @@ image_viewer::show_attachment(attachment* a)

m_image_label->resize(m_scale_factor * m_image_label->pixmap()->size());
show();
}
}
}

image_label::image_label(QWidget* parent) : QLabel(parent)
Expand Down

0 comments on commit 198371f

Please sign in to comment.