Commit 0ca006911dfb5a415b08da7889ea719f9fa02ecd
1 parent
771d8514
Empty lists can and do happen
Showing
1 changed file
with
2 additions
and
2 deletions
openbr/openbr_plugin.cpp
| ... | ... | @@ -428,7 +428,7 @@ br_utemplate Template::toUniversalTemplate(const Template &t) |
| 428 | 428 | // lists of points and rects, too |
| 429 | 429 | else if (v.type() == QVariant::List) { |
| 430 | 430 | QVariantList oldlist = qvariant_cast<QVariantList>(v); |
| 431 | - if (oldlist.first().canConvert(QVariant::PointF) || oldlist.first().canConvert(QVariant::RectF)) { | |
| 431 | + if (!oldlist.isEmpty() && (oldlist.first().canConvert(QVariant::PointF) || oldlist.first().canConvert(QVariant::RectF))) { | |
| 432 | 432 | QVariantList newlist; |
| 433 | 433 | foreach (const QVariant &subv, oldlist) { |
| 434 | 434 | newlist.append(QtUtils::toString(subv)); |
| ... | ... | @@ -472,7 +472,7 @@ Template Template::fromUniversalTemplate(br_const_utemplate ut) |
| 472 | 472 | // convert lists of rects and points, too |
| 473 | 473 | else if (v.type() == QVariant::List) { |
| 474 | 474 | QVariantList oldlist = qvariant_cast<QVariantList>(v); |
| 475 | - if (oldlist.first().type() == QVariant::String) { | |
| 475 | + if (!oldlist.isEmpty() && oldlist.first().type() == QVariant::String) { | |
| 476 | 476 | QString test = qvariant_cast<QString>(oldlist.first()); |
| 477 | 477 | QtUtils::toRect(test, &istype); |
| 478 | 478 | QVariantList newlist; | ... | ... |