mirror of
https://github.com/Palakis/obs-websocket.git
synced 2024-08-30 18:12:16 +00:00
Utils: Add retrocompatability header
QRunnable::create was added in Qt 5.15, but Ubuntu still uses 5.12. This reimplements that functionality until Ubuntu moves to >= 5.15
This commit is contained in:
parent
7a888c2f92
commit
78d02696d0
16
src/utils/Compat.cpp
Normal file
16
src/utils/Compat.cpp
Normal file
@ -0,0 +1,16 @@
|
||||
#include "Compat.h"
|
||||
|
||||
Utils::Compat::StdFunctionRunnable::StdFunctionRunnable(std::function<void()> func) :
|
||||
cb(std::move(func))
|
||||
{
|
||||
}
|
||||
|
||||
void Utils::Compat::StdFunctionRunnable::run()
|
||||
{
|
||||
cb();
|
||||
}
|
||||
|
||||
QRunnable *Utils::Compat::CreateFunctionRunnable(std::function<void()> func)
|
||||
{
|
||||
return new Utils::Compat::StdFunctionRunnable(std::move(func));
|
||||
}
|
18
src/utils/Compat.h
Normal file
18
src/utils/Compat.h
Normal file
@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include <functional>
|
||||
#include <QRunnable>
|
||||
|
||||
namespace Utils {
|
||||
namespace Compat {
|
||||
// Reimplement QRunnable for std::function. Retrocompatability for Qt < 5.15
|
||||
class StdFunctionRunnable : public QRunnable {
|
||||
std::function<void()> cb;
|
||||
public:
|
||||
StdFunctionRunnable(std::function<void()> func);
|
||||
void run() override;
|
||||
};
|
||||
|
||||
QRunnable *CreateFunctionRunnable(std::function<void()> func);
|
||||
}
|
||||
}
|
@ -4,3 +4,4 @@
|
||||
#include "Json.h"
|
||||
#include "Obs.h"
|
||||
#include "Platform.h"
|
||||
#include "Compat.h"
|
||||
|
Loading…
Reference in New Issue
Block a user