2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 14:45:14 +00:00

Made base::lambda a copyable value type.

Now base::lambda can be copied and can wrap any immutable lambda.
For mutable lambdas there is base::lambda_once (which you're
supposed to call only once to pass data through lambda captures,
for example by using std::unique_ptr). Generally base::lambda is
passed by value and base::lambda_once is passed by rvalue reference.
This commit is contained in:
John Preston
2017-02-26 14:32:13 +03:00
parent f82989c9c3
commit c207743338
78 changed files with 662 additions and 633 deletions

View File

@@ -798,7 +798,7 @@ bool CopyColorsToPalette(const QString &path, const QByteArray &themeContent) {
return true;
}
bool ReadPaletteValues(const QByteArray &content, base::lambda<bool(QLatin1String name, QLatin1String value)> &&callback) {
bool ReadPaletteValues(const QByteArray &content, base::lambda<bool(QLatin1String name, QLatin1String value)> callback) {
if (content.size() > kThemeSchemeSizeLimit) {
LOG(("Theme Error: color scheme file too large (should be less than 1 MB, got %2)").arg(content.size()));
return false;

View File

@@ -141,7 +141,7 @@ void ComputeBackgroundRects(QRect wholeFill, QSize imageSize, QRect &to, QRect &
bool CopyColorsToPalette(const QString &path, const QByteArray &themeContent);
bool ReadPaletteValues(const QByteArray &content, base::lambda<bool(QLatin1String name, QLatin1String value)> &&callback);
bool ReadPaletteValues(const QByteArray &content, base::lambda<bool(QLatin1String name, QLatin1String value)> callback);
} // namespace Theme
} // namespace Window

View File

@@ -208,13 +208,13 @@ class Editor::Inner : public TWidget, private base::Subscriber {
public:
Inner(QWidget *parent, const QString &path);
void setErrorCallback(base::lambda<void()> &&callback) {
void setErrorCallback(base::lambda<void()> callback) {
_errorCallback = std::move(callback);
}
void setFocusCallback(base::lambda<void()> &&callback) {
void setFocusCallback(base::lambda<void()> callback) {
_focusCallback = std::move(callback);
}
void setScrollCallback(base::lambda<void(int top, int bottom)> &&callback) {
void setScrollCallback(base::lambda<void(int top, int bottom)> callback) {
_scrollCallback = std::move(callback);
}

View File

@@ -31,7 +31,7 @@ class WarningWidget : public TWidget {
public:
WarningWidget(QWidget *parent);
void setHiddenCallback(base::lambda<void()> &&callback) {
void setHiddenCallback(base::lambda<void()> callback) {
_hiddenCallback = std::move(callback);
}