Skip to content

Commit f5f8e9e

Browse files
author
Fabien Servant
committed
Make sure cameraInit change does not clear cache
1 parent 6bac381 commit f5f8e9e

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

src/qtAliceVision/AsyncFetcher.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ class AsyncFetcher : public QObject, public QRunnable
6767
*/
6868
void stopAsync();
6969

70+
bool isAsync() const
71+
{
72+
return _isAsynchroneous;
73+
}
74+
7075
/**
7176
* @brief get the cache content size in bytes
7277
* @return the cache content size in bytes

src/qtAliceVision/FloatImageViewer.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,11 +185,13 @@ QVector4D FloatImageViewer::pixelValueAt(int x, int y)
185185
{
186186
if (!_image)
187187
{
188+
std::cout << "error no image" << std::endl;
188189
// qInfo() << "[QtAliceVision] FloatImageViewer::pixelValueAt(" << x << ", " << y << ") => no valid image";
189190
return QVector4D(0.0, 0.0, 0.0, 0.0);
190191
}
191192
else if (x < 0 || x >= _image->width() || y < 0 || y >= _image->height())
192193
{
194+
std::cout << "error out of image " << x << " " << _image->width() << " " << y << " " << _image->height()<< std::endl;
193195
// qInfo() << "[QtAliceVision] FloatImageViewer::pixelValueAt(" << x << ", " << y << ") => out of range";
194196
return QVector4D(0.0, 0.0, 0.0, 0.0);
195197
}

src/qtAliceVision/SequenceCache.cpp

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ SequenceCache::SequenceCache(QObject* parent)
2424
_maxMemory = static_cast<size_t>(cacheRam);
2525

2626
_fetcher.setAutoDelete(false);
27+
28+
//Cache does not exist
29+
//Let's create a new one !
30+
{
31+
image::ImageCache::uptr cache = std::make_unique<image::ImageCache>(_maxMemory, image::EImageColorSpace::LINEAR);
32+
_fetcher.setCache(std::move(cache));
33+
}
2734
}
2835

2936
SequenceCache::~SequenceCache()
@@ -34,16 +41,11 @@ SequenceCache::~SequenceCache()
3441

3542
void SequenceCache::setSequence(const QVariantList& paths)
3643
{
44+
bool isAsync = _fetcher.isAsync();
45+
3746
_fetcher.stopAsync();
3847
_threadPool.waitForDone();
3948

40-
//On changing sequence, the cache become totally invalid
41-
//Let's create a new one !
42-
{
43-
image::ImageCache::uptr cache = std::make_unique<image::ImageCache>(_maxMemory, image::EImageColorSpace::LINEAR);
44-
_fetcher.setCache(std::move(cache));
45-
}
46-
4749
//Convert to string
4850
std::vector<std::string> sequence;
4951
for (const auto & item : paths)
@@ -53,6 +55,9 @@ void SequenceCache::setSequence(const QVariantList& paths)
5355

5456
//Assign sequence to fetcher
5557
_fetcher.setSequence(sequence);
58+
59+
//Restart if needed
60+
setAsyncFetching(isAsync);
5661
}
5762

5863
void SequenceCache::setResizeRatio(double ratio)

0 commit comments

Comments
 (0)