Fix build with macOS deployment target < 10.14

As is used for the Qt 5 based prebuilt binaries.
std::optional is only fully supported out of the box since
10.14.

Change-Id: Ide8bd9ac8b66b05e1bb6e9b350edf3e7ffdaf97e
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Eike Ziller
2022-01-07 14:54:40 +01:00
parent 3c2c8b97a1
commit 80e0cb56ec
8 changed files with 20 additions and 17 deletions

View File

@@ -115,7 +115,7 @@ void AsynchronousExplicitImageCache::clean()
clearEntries();
}
std::optional<AsynchronousExplicitImageCache::RequestEntry> AsynchronousExplicitImageCache::getEntry()
Utils::optional<AsynchronousExplicitImageCache::RequestEntry> AsynchronousExplicitImageCache::getEntry()
{
std::unique_lock lock{m_mutex};

View File

@@ -145,7 +145,7 @@ void AsynchronousImageCache::clean()
m_generator.clean();
}
std::optional<AsynchronousImageCache::Entry> AsynchronousImageCache::getEntry()
Utils::optional<AsynchronousImageCache::Entry> AsynchronousImageCache::getEntry()
{
std::unique_lock lock{m_mutex};

View File

@@ -90,7 +90,7 @@ void AsynchronousImageFactory::waitForEntries()
m_condition.wait(lock, [&] { return m_entries.size() || m_finishing; });
}
std::optional<AsynchronousImageFactory::Entry> AsynchronousImageFactory::getEntry()
Utils::optional<AsynchronousImageFactory::Entry> AsynchronousImageFactory::getEntry()
{
std::unique_lock lock{m_mutex};

View File

@@ -27,12 +27,12 @@
#include "imagecacheauxiliarydata.h"
#include <utils/optional.h>
#include <utils/smallstring.h>
#include <condition_variable>
#include <deque>
#include <mutex>
#include <optional>
#include <thread>
namespace QmlDesigner {
@@ -78,7 +78,7 @@ private:
ImageCache::AuxiliaryData &&auxiliaryData);
bool isRunning();
void waitForEntries();
std::optional<Entry> getEntry();
Utils::optional<Entry> getEntry();
void request(Utils::SmallStringView name,
Utils::SmallStringView extraId,
ImageCache::AuxiliaryData auxiliaryData,

View File

@@ -29,6 +29,7 @@
#include <QImage>
#include <sqlitetimestamp.h>
#include <utils/optional.h>
#include <utils/smallstringview.h>
namespace QmlDesigner {
@@ -36,8 +37,8 @@ namespace QmlDesigner {
class ImageCacheStorageInterface
{
public:
using ImageEntry = std::optional<QImage>;
using IconEntry = std::optional<QIcon>;
using ImageEntry = Utils::optional<QImage>;
using IconEntry = Utils::optional<QIcon>;
virtual ImageEntry fetchImage(Utils::SmallStringView name,
Sqlite::TimeStamp minimumTimeStamp) const = 0;

View File

@@ -27,11 +27,12 @@
#include "asynchronousimagecacheinterface.h"
#include <utils/optional.h>
#include <condition_variable>
#include <deque>
#include <functional>
#include <mutex>
#include <optional>
#include <thread>
namespace QmlDesigner {
@@ -80,7 +81,7 @@ private:
RequestType requestType = RequestType::Image;
};
std::optional<RequestEntry> getEntry();
Utils::optional<RequestEntry> getEntry();
void addEntry(Utils::PathString &&name,
Utils::SmallString &&extraId,
ImageCache::CaptureImageCallback &&captureCallback,

View File

@@ -27,11 +27,12 @@
#include "asynchronousimagecacheinterface.h"
#include <utils/optional.h>
#include <condition_variable>
#include <deque>
#include <functional>
#include <mutex>
#include <optional>
#include <thread>
namespace QmlDesigner {
@@ -90,7 +91,7 @@ private:
RequestType requestType = RequestType::Image;
};
std::optional<Entry> getEntry();
Utils::optional<Entry> getEntry();
void addEntry(Utils::PathString &&name,
Utils::SmallString &&extraId,
ImageCache::CaptureImageCallback &&captureCallback,

View File

@@ -306,7 +306,7 @@ TEST_F(ImageCacheStorageSlowTest, FetchNonExistingImageIsEmpty)
{
auto image = storage.fetchImage("/path/to/component", {123});
ASSERT_THAT(image, Eq(std::nullopt));
ASSERT_THAT(image, Eq(Utils::nullopt));
}
TEST_F(ImageCacheStorageSlowTest, FetchSameTimeImage)
@@ -324,7 +324,7 @@ TEST_F(ImageCacheStorageSlowTest, DoNotFetchOlderImage)
auto image = storage.fetchImage("/path/to/component", {124});
ASSERT_THAT(image, Eq(std::nullopt));
ASSERT_THAT(image, Eq(Utils::nullopt));
}
TEST_F(ImageCacheStorageSlowTest, FetchNewerImage)
@@ -340,7 +340,7 @@ TEST_F(ImageCacheStorageSlowTest, FetchNonExistingSmallImageIsEmpty)
{
auto image = storage.fetchSmallImage("/path/to/component", {123});
ASSERT_THAT(image, Eq(std::nullopt));
ASSERT_THAT(image, Eq(Utils::nullopt));
}
TEST_F(ImageCacheStorageSlowTest, FetchSameTimeSmallImage)
@@ -358,7 +358,7 @@ TEST_F(ImageCacheStorageSlowTest, DoNotFetchOlderSmallImage)
auto image = storage.fetchSmallImage("/path/to/component", {124});
ASSERT_THAT(image, Eq(std::nullopt));
ASSERT_THAT(image, Eq(Utils::nullopt));
}
TEST_F(ImageCacheStorageSlowTest, FetchNewerSmallImage)
@@ -397,7 +397,7 @@ TEST_F(ImageCacheStorageSlowTest, FetchNonExistingIconIsEmpty)
{
auto image = storage.fetchIcon("/path/to/component", {123});
ASSERT_THAT(image, Eq(std::nullopt));
ASSERT_THAT(image, Eq(Utils::nullopt));
}
TEST_F(ImageCacheStorageSlowTest, FetchSameTimeIcon)
@@ -415,7 +415,7 @@ TEST_F(ImageCacheStorageSlowTest, DoNotFetchOlderIcon)
auto image = storage.fetchIcon("/path/to/component", {124});
ASSERT_THAT(image, Eq(std::nullopt));
ASSERT_THAT(image, Eq(Utils::nullopt));
}
TEST_F(ImageCacheStorageSlowTest, FetchNewerIcon)