Try to fix crash in ImageRingList
This commit is contained in:
@@ -111,7 +111,7 @@ void Image::thumbnailLoadFinish(std::shared_ptr<RawImage> rawImage)
|
|||||||
emit thumbnailLoaded(this);
|
emit thumbnailLoaded(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
ImageRingList::ImageRingList(Database *database, const QStringList &nameFilter, QObject *parent) : QAbstractItemModel(parent)
|
ImageRingList::ImageRingList(Database *database, const QStringList &nameFilter, QObject *parent) : QAbstractListModel(parent)
|
||||||
, m_liveMode(false)
|
, m_liveMode(false)
|
||||||
, m_analyzeLevel(None)
|
, m_analyzeLevel(None)
|
||||||
, m_database(database)
|
, m_database(database)
|
||||||
@@ -412,7 +412,7 @@ void ImageRingList::clearThumbnails()
|
|||||||
img->clearThumbnail();
|
img->clearThumbnail();
|
||||||
}
|
}
|
||||||
|
|
||||||
QModelIndex ImageRingList::index(int row, int column, const QModelIndex &parent) const
|
/*QModelIndex ImageRingList::index(int row, int column, const QModelIndex &parent) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(parent);
|
Q_UNUSED(parent);
|
||||||
return createIndex(row, column, m_images.at(row).get());
|
return createIndex(row, column, m_images.at(row).get());
|
||||||
@@ -422,7 +422,7 @@ QModelIndex ImageRingList::parent(const QModelIndex &child) const
|
|||||||
{
|
{
|
||||||
Q_UNUSED(child);
|
Q_UNUSED(child);
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
}
|
}*/
|
||||||
|
|
||||||
int ImageRingList::rowCount(const QModelIndex &parent) const
|
int ImageRingList::rowCount(const QModelIndex &parent) const
|
||||||
{
|
{
|
||||||
@@ -432,13 +432,15 @@ int ImageRingList::rowCount(const QModelIndex &parent) const
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ImageRingList::columnCount(const QModelIndex &parent) const
|
/*int ImageRingList::columnCount(const QModelIndex &parent) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(parent);
|
Q_UNUSED(parent);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
QVariant ImageRingList::data(const QModelIndex &index, int role) const
|
QVariant ImageRingList::data(const QModelIndex &index, int role) const
|
||||||
|
{
|
||||||
|
if(index.isValid() && index.row() >= 0 && index.row() < m_images.size())
|
||||||
{
|
{
|
||||||
switch(role)
|
switch(role)
|
||||||
{
|
{
|
||||||
@@ -458,6 +460,8 @@ QVariant ImageRingList::data(const QModelIndex &index, int role) const
|
|||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
QVariant ImageRingList::headerData(int section, Qt::Orientation orientation, int role) const
|
QVariant ImageRingList::headerData(int section, Qt::Orientation orientation, int role) const
|
||||||
{
|
{
|
||||||
|
|||||||
+4
-4
@@ -51,7 +51,7 @@ typedef std::shared_ptr<Image> ImagePtr;
|
|||||||
|
|
||||||
class Database;
|
class Database;
|
||||||
|
|
||||||
class ImageRingList : public QAbstractItemModel
|
class ImageRingList : public QAbstractListModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
int m_width;
|
int m_width;
|
||||||
@@ -93,10 +93,10 @@ public:
|
|||||||
void updateMark();
|
void updateMark();
|
||||||
void clearThumbnails();
|
void clearThumbnails();
|
||||||
|
|
||||||
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
|
//QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
|
||||||
QModelIndex parent(const QModelIndex &child) const override;
|
//QModelIndex parent(const QModelIndex &child) const override;
|
||||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||||
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
//int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||||
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
||||||
public slots:
|
public slots:
|
||||||
|
|||||||
Reference in New Issue
Block a user