render: fix issue responding to cancelled tasks
This commit is contained in:
@@ -55,8 +55,6 @@ set(OLIVE_SOURCES
|
||||
common/ratiodialog.h
|
||||
common/rational.cpp
|
||||
common/rational.h
|
||||
common/threadedobject.cpp
|
||||
common/threadedobject.h
|
||||
common/threadsafemap.h
|
||||
common/timecodefunctions.cpp
|
||||
common/timecodefunctions.h
|
||||
|
||||
@@ -21,35 +21,38 @@
|
||||
#ifndef CANCELABLEOBJECT_H
|
||||
#define CANCELABLEOBJECT_H
|
||||
|
||||
#include <QAtomicInt>
|
||||
|
||||
#include "common/define.h"
|
||||
#include "render/cancelatom.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
class CancelableObject {
|
||||
public:
|
||||
CancelableObject() :
|
||||
cancelled_(false)
|
||||
CancelableObject()
|
||||
{
|
||||
}
|
||||
|
||||
void Cancel()
|
||||
{
|
||||
cancelled_ = true;
|
||||
cancel_.Cancel();
|
||||
CancelEvent();
|
||||
}
|
||||
|
||||
const QAtomicInt& IsCancelled() const
|
||||
CancelAtom *GetCancelAtom()
|
||||
{
|
||||
return cancelled_;
|
||||
return &cancel_;
|
||||
}
|
||||
|
||||
bool IsCancelled()
|
||||
{
|
||||
return cancel_.IsCancelled();
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual void CancelEvent(){}
|
||||
|
||||
private:
|
||||
QAtomicInt cancelled_;
|
||||
CancelAtom cancel_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2022 Olive Team
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#include "threadedobject.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
void ThreadedObject::LockDeletes()
|
||||
{
|
||||
threadobj_delete_lock_++;
|
||||
}
|
||||
|
||||
void ThreadedObject::UnlockDeletes()
|
||||
{
|
||||
Q_ASSERT(AreDeletesLocked());
|
||||
|
||||
threadobj_delete_lock_--;
|
||||
}
|
||||
|
||||
bool ThreadedObject::AreDeletesLocked()
|
||||
{
|
||||
return (threadobj_delete_lock_ > 0);
|
||||
}
|
||||
|
||||
void ThreadedObject::LockMutex()
|
||||
{
|
||||
threadobj_main_lock_.lock();
|
||||
}
|
||||
|
||||
void ThreadedObject::UnlockMutex()
|
||||
{
|
||||
threadobj_main_lock_.unlock();
|
||||
}
|
||||
|
||||
bool ThreadedObject::TryLockMutex(int timeout)
|
||||
{
|
||||
return threadobj_main_lock_.tryLock(timeout);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2022 Olive Team
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#ifndef THREADEDOBJECT_H
|
||||
#define THREADEDOBJECT_H
|
||||
|
||||
#include <QMutex>
|
||||
|
||||
#include "common/define.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
class ThreadedObject
|
||||
{
|
||||
public:
|
||||
|
||||
void LockMutex();
|
||||
void UnlockMutex();
|
||||
bool TryLockMutex(int timeout = 0);
|
||||
|
||||
void LockDeletes();
|
||||
void UnlockDeletes();
|
||||
bool AreDeletesLocked();
|
||||
|
||||
private:
|
||||
QMutex threadobj_main_lock_;
|
||||
|
||||
QAtomicInt threadobj_delete_lock_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // THREADEDOBJECT_H
|
||||
Reference in New Issue
Block a user