mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
core: default initialize units-type objects to 0
Makes the code much nicer to read. Default initialize cylinder_t to the empty cylinder. This produces lots of warnings, because most structure are now not PODs anymore and shouldn't be erased using memset(). These memset()s will be removed one-by-one and replaced by proper constructors. The whole ordeal made it necessary to add a constructor to struct event. To simplify things the whole optimization of the variable-size event names was removed. In upcoming commits this will be replaced by std::string anyway. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
b82fdd1d20
commit
408b31b6ce
34 changed files with 128 additions and 148 deletions
|
@ -96,7 +96,7 @@ Thumbnailer::Thumbnail Thumbnailer::fetchImage(const QString &urlfilename, const
|
|||
|
||||
// For io error or video, return early with the appropriate dummy-icon.
|
||||
if (type == MEDIATYPE_IO_ERROR)
|
||||
return { failImage, MEDIATYPE_IO_ERROR, zero_duration };
|
||||
return { failImage, MEDIATYPE_IO_ERROR, duration_t() };
|
||||
else if (type == MEDIATYPE_VIDEO)
|
||||
return fetchVideoThumbnail(filename, originalFilename, md.duration);
|
||||
|
||||
|
@ -112,7 +112,7 @@ Thumbnailer::Thumbnail Thumbnailer::fetchImage(const QString &urlfilename, const
|
|||
// Try to check for a video-file extension. Since we couldn't parse the video file,
|
||||
// we pass 0 as the duration.
|
||||
if (hasVideoFileExtension(filename))
|
||||
return fetchVideoThumbnail(filename, originalFilename, zero_duration);
|
||||
return fetchVideoThumbnail(filename, originalFilename, duration_t());
|
||||
|
||||
// Give up: we simply couldn't determine what this thing is.
|
||||
// But since we managed to read this file, mark this file in the cache as unknown.
|
||||
|
@ -122,9 +122,9 @@ Thumbnailer::Thumbnail Thumbnailer::fetchImage(const QString &urlfilename, const
|
|||
// to treat requests from other threads. invokeMethod() is Qt's way of calling a
|
||||
// function in a different thread, namely the thread the called object is associated to.
|
||||
QMetaObject::invokeMethod(ImageDownloader::instance(), "load", Qt::AutoConnection, Q_ARG(QUrl, url), Q_ARG(QString, originalFilename));
|
||||
return { QImage(), MEDIATYPE_STILL_LOADING, zero_duration };
|
||||
return { QImage(), MEDIATYPE_STILL_LOADING, duration_t() };
|
||||
}
|
||||
return { QImage(), MEDIATYPE_IO_ERROR, zero_duration };
|
||||
return { QImage(), MEDIATYPE_IO_ERROR, duration_t() };
|
||||
}
|
||||
|
||||
// Fetch a picture based on its original filename. If there is a translated filename (obtained either
|
||||
|
@ -140,7 +140,7 @@ Thumbnailer::Thumbnail Thumbnailer::getHashedImage(const QString &filename, bool
|
|||
// If there is a translated filename, try that first.
|
||||
// Note that we set the default type to io-error, so that if we didn't try
|
||||
// the local filename first, we will load the file from the canonical filename.
|
||||
Thumbnail thumbnail { QImage(), MEDIATYPE_IO_ERROR, zero_duration };
|
||||
Thumbnail thumbnail { QImage(), MEDIATYPE_IO_ERROR, duration_t() };
|
||||
if (localFilename != filename)
|
||||
thumbnail = fetchImage(localFilename, filename, tryDownload);
|
||||
|
||||
|
@ -187,7 +187,7 @@ Thumbnailer::Thumbnail Thumbnailer::getPictureThumbnailFromStream(QDataStream &s
|
|||
{
|
||||
QImage res;
|
||||
stream >> res;
|
||||
return { std::move(res), MEDIATYPE_PICTURE, zero_duration };
|
||||
return { std::move(res), MEDIATYPE_PICTURE, duration_t() };
|
||||
}
|
||||
|
||||
void Thumbnailer::markVideoThumbnail(QImage &img)
|
||||
|
@ -210,7 +210,7 @@ Thumbnailer::Thumbnail Thumbnailer::getVideoThumbnailFromStream(QDataStream &str
|
|||
// Likewise test the duration and number of pictures for sanity (no videos longer than 10 h,
|
||||
// no more than 10000 pictures).
|
||||
if (stream.status() != QDataStream::Ok || duration > 36000 || numPics > 10000)
|
||||
return { QImage(), MEDIATYPE_VIDEO, zero_duration };
|
||||
return { QImage(), MEDIATYPE_VIDEO, duration_t() };
|
||||
|
||||
// If the file didn't contain an image, but user turned on thumbnail extraction, schedule thumbnail
|
||||
// for extraction. TODO: save failure to extract thumbnails to disk so that thumbnailing
|
||||
|
@ -240,7 +240,7 @@ Thumbnailer::Thumbnail Thumbnailer::getThumbnailFromCache(const QString &picture
|
|||
{
|
||||
QString filename = thumbnailFileName(picture_filename);
|
||||
if (filename.isEmpty())
|
||||
return { QImage(), MEDIATYPE_UNKNOWN, zero_duration };
|
||||
return { QImage(), MEDIATYPE_UNKNOWN, duration_t() };
|
||||
QFile file(filename);
|
||||
|
||||
if (prefs.auto_recalculate_thumbnails) {
|
||||
|
@ -254,13 +254,13 @@ Thumbnailer::Thumbnail Thumbnailer::getThumbnailFromCache(const QString &picture
|
|||
if (pictureTime.isValid() && thumbnailTime.isValid() && thumbnailTime < pictureTime) {
|
||||
// Both files exist, have valid timestamps and thumbnail was calculated before picture.
|
||||
// Return an empty thumbnail to signal recalculation of the thumbnail
|
||||
return { QImage(), MEDIATYPE_UNKNOWN, zero_duration };
|
||||
return { QImage(), MEDIATYPE_UNKNOWN, duration_t() };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!file.open(QIODevice::ReadOnly))
|
||||
return { QImage(), MEDIATYPE_UNKNOWN, zero_duration };
|
||||
return { QImage(), MEDIATYPE_UNKNOWN, duration_t() };
|
||||
QDataStream stream(&file);
|
||||
|
||||
// Each thumbnail file is composed of a media-type and an image file.
|
||||
|
@ -271,8 +271,8 @@ Thumbnailer::Thumbnail Thumbnailer::getThumbnailFromCache(const QString &picture
|
|||
switch (type) {
|
||||
case MEDIATYPE_PICTURE: return getPictureThumbnailFromStream(stream);
|
||||
case MEDIATYPE_VIDEO: return getVideoThumbnailFromStream(stream, picture_filename);
|
||||
case MEDIATYPE_UNKNOWN: return { unknownImage, MEDIATYPE_UNKNOWN, zero_duration };
|
||||
default: return { QImage(), MEDIATYPE_UNKNOWN, zero_duration };
|
||||
case MEDIATYPE_UNKNOWN: return { unknownImage, MEDIATYPE_UNKNOWN, duration_t() };
|
||||
default: return { QImage(), MEDIATYPE_UNKNOWN, duration_t() };
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -319,7 +319,7 @@ Thumbnailer::Thumbnail Thumbnailer::fetchVideoThumbnail(const QString &filename,
|
|||
return { videoImage, MEDIATYPE_VIDEO, duration };
|
||||
} else {
|
||||
// Video-thumbnailing is disabled. Write a thumbnail without picture.
|
||||
return addVideoThumbnailToCache(originalFilename, duration, QImage(), zero_duration);
|
||||
return addVideoThumbnailToCache(originalFilename, duration, QImage(), duration_t());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -337,7 +337,7 @@ Thumbnailer::Thumbnail Thumbnailer::addPictureThumbnailToCache(const QString &pi
|
|||
stream << thumbnail;
|
||||
file.commit();
|
||||
}
|
||||
return { thumbnail, MEDIATYPE_PICTURE, zero_duration };
|
||||
return { thumbnail, MEDIATYPE_PICTURE, duration_t() };
|
||||
}
|
||||
|
||||
Thumbnailer::Thumbnail Thumbnailer::addUnknownThumbnailToCache(const QString &picture_filename)
|
||||
|
@ -348,7 +348,7 @@ Thumbnailer::Thumbnail Thumbnailer::addUnknownThumbnailToCache(const QString &pi
|
|||
QDataStream stream(&file);
|
||||
stream << (quint32)MEDIATYPE_UNKNOWN;
|
||||
}
|
||||
return { unknownImage, MEDIATYPE_UNKNOWN, zero_duration };
|
||||
return { unknownImage, MEDIATYPE_UNKNOWN, duration_t() };
|
||||
}
|
||||
|
||||
void Thumbnailer::frameExtracted(QString filename, QImage thumbnail, duration_t duration, duration_t offset)
|
||||
|
@ -374,7 +374,7 @@ void Thumbnailer::frameExtractionFailed(QString filename, duration_t duration)
|
|||
{
|
||||
// Frame extraction failed, but this was due to ffmpeg not starting
|
||||
// add to the thumbnail cache as a video image with unknown thumbnail.
|
||||
addVideoThumbnailToCache(filename, duration, QImage(), zero_duration);
|
||||
addVideoThumbnailToCache(filename, duration, QImage(), duration_t());
|
||||
QMutexLocker l(&lock);
|
||||
workingOn.remove(filename);
|
||||
}
|
||||
|
@ -435,7 +435,7 @@ void Thumbnailer::imageDownloaded(QString filename)
|
|||
|
||||
void Thumbnailer::imageDownloadFailed(QString filename)
|
||||
{
|
||||
emit thumbnailChanged(filename, failImage, zero_duration);
|
||||
emit thumbnailChanged(filename, failImage, duration_t());
|
||||
QMutexLocker l(&lock);
|
||||
workingOn.remove(filename);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue