Commit 2fa633df authored by Marcel Wiesweg's avatar Marcel Wiesweg
Browse files

Dont crash trying to add an empty list:

Filtering for mimetype is not appropriate in the core of the model.
As this seems to be about filtering out invalid entries, move it to the Controller.

BUG: 310163
parent ba67ae87
......@@ -510,15 +510,17 @@ void CameraController::executeCommand(CameraCommand* const cmd)
CamItemInfoList list;
foreach(CamItemInfo info, itemsList)
{
if (info.mime.isEmpty())
{
// skip
continue;
}
numberOfItems++;
info.id += numberOfItems;
list.append(info);
}
if (!list.isEmpty())
{
emit signalFileList(list);
}
emit signalFileList(list);
sendLogMsg(i18n("The files in %1 have been listed.", folder));
......
......@@ -605,39 +605,25 @@ void ImportImageModel::publiciseInfos(const QList<CamItemInfo>& infos)
emit itemInfosAboutToBeAdded(infos);
QList<CamItemInfo> newInfos;
// check if the new infos have a known file type.
foreach (CamItemInfo info, infos)
{
if (info.mime != "")
{
newInfos << info;
}
}
const int firstNewIndex = d->infos.size();
const int lastNewIndex = d->infos.size() + newInfos.size() -1;
const int lastNewIndex = d->infos.size() + infos.size() -1;
beginInsertRows(QModelIndex(), firstNewIndex, lastNewIndex);
d->infos << newInfos;
d->infos << infos;
for (int i = firstNewIndex; i <= lastNewIndex; ++i)
{
const CamItemInfo& info = d->infos.at(i);
if (info.mime != "")
{
qlonglong id = info.id;
d->idHash.insertMulti(id, i);
qlonglong id = info.id;
d->idHash.insertMulti(id, i);
if (d->keepFileUrlCache)
{
d->fileUrlHash[info.url().prettyUrl()] = id;
}
if (d->keepFileUrlCache)
{
d->fileUrlHash[info.url().prettyUrl()] = id;
}
}
endInsertRows();
emit itemInfosAdded(newInfos);
emit itemInfosAdded(infos);
}
void ImportImageModel::requestIncrementalRefresh()
......
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