mirror of
https://gitlab.com/eql/lqml.git
synced 2025-12-06 10:31:34 -08:00
example 'qsqlite': fix crash if image is not found
This commit is contained in:
parent
1411f44994
commit
7ae3cfb04a
1 changed files with 7 additions and 5 deletions
|
|
@ -82,12 +82,14 @@ QPixmap DatabaseImageProvider::requestPixmap(const QString& name, QSize* size, c
|
|||
auto result = qt->sqlQuery(
|
||||
"select data from images where name = ?",
|
||||
QVariantList() << name,
|
||||
1); // number of returned columns
|
||||
1).value<QVariantList>(); // number of returned columns
|
||||
QPixmap pixmap;
|
||||
pixmap.loadFromData(result.value<QVariantList>().first().toByteArray());
|
||||
*size = pixmap.size();
|
||||
if (requestedSize.isValid() && (pixmap.size() != requestedSize)) {
|
||||
pixmap = pixmap.scaled(requestedSize);
|
||||
if (!result.isEmpty()) {
|
||||
pixmap.loadFromData(result.first().toByteArray());
|
||||
*size = pixmap.size();
|
||||
if (requestedSize.isValid() && (pixmap.size() != requestedSize)) {
|
||||
pixmap = pixmap.scaled(requestedSize);
|
||||
}
|
||||
}
|
||||
return pixmap;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue