mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-09-25 07:50:39 -05:00
UI: Add CreateQThread helper function
Allows creating a QThread via an std::function. A backward-compatible alternative to QThread::create for Qt versions older than 5.10 (when it became available in Qt).
This commit is contained in:
@@ -203,3 +203,23 @@ void DeleteLayout(QLayout *layout)
|
||||
|
||||
delete layout;
|
||||
}
|
||||
|
||||
class QuickThread : public QThread {
|
||||
public:
|
||||
explicit inline QuickThread(std::function<void()> func_)
|
||||
: func(func_)
|
||||
{}
|
||||
|
||||
private:
|
||||
virtual void run() override
|
||||
{
|
||||
func();
|
||||
}
|
||||
|
||||
std::function<void()> func;
|
||||
};
|
||||
|
||||
QThread *CreateQThread(std::function<void()> func)
|
||||
{
|
||||
return new QuickThread(func);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user