Fix compiling with latest libgui version

This commit is contained in:
Maschell 2020-04-27 13:06:59 +02:00
parent 74158fea6e
commit e46ca4901a
7 changed files with 23 additions and 33 deletions

2
.gitignore vendored
View File

@ -3,3 +3,5 @@ build/
*.elf
*.exe
src/resources/filelist.h
*.wbf
out/

View File

@ -52,7 +52,7 @@ LIBS := -lgui -lfreetype -lgd -lpng -ljpeg -lz -lmad -lvorbisidec -logg -lbz2 -
# list of directories containing libraries, this must be the top level
# containing include and lib
#-------------------------------------------------------------------------------
LIBDIRS := $(PORTLIBS) $(WUT_ROOT)
LIBDIRS := $(PORTLIBS) $(WUT_ROOT) $(WUT_ROOT)/usr
#-------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional

View File

@ -25,6 +25,7 @@
#include "resources/Resources.h"
#include "gui/sounds/SoundHandler.hpp"
#include "system/memory.h"
#include "system/AsyncDeleter.h"
#include "utils/logger.h"
Application *Application::applicationInstance = NULL;

View File

@ -14,6 +14,7 @@
* 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 <coreinit/time.h>
#include "Pipe.h"
#include "gui/GuiTrigger.h"
#include "gui/GuiController.h"

View File

@ -21,6 +21,7 @@
#include "utils/StringTools.h"
#include "utils/logger.h"
#include "resources/Resources.h"
#include "system/AsyncDeleter.h"
MainWindow::MainWindow(int w, int h)
: width(w)

View File

@ -14,7 +14,7 @@
* 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 <system/AsyncDeleter.h>
#include "AsyncDeleter.h"
AsyncDeleter * AsyncDeleter::deleterInstance = NULL;
@ -28,9 +28,8 @@ AsyncDeleter::~AsyncDeleter() {
}
void AsyncDeleter::triggerDeleteProcess(void) {
if(!deleterInstance){
return;
}
if(!deleterInstance)
deleterInstance = new AsyncDeleter;
//! to trigger the event after GUI process is finished execution
//! this function is used to swap elements from one to next array
@ -46,13 +45,14 @@ void AsyncDeleter::triggerDeleteProcess(void) {
}
void AsyncDeleter::executeThread(void) {
while(!exitApplication || !realDeleteElements.empty()) {
if(realDeleteElements.empty()) suspendThread();
while(!exitApplication) {
suspendThread();
//! delete elements that require post process deleting
//! because otherwise they would block or do invalid access on GUI thread
while(!realDeleteElements.empty()) {
deleteMutex.lock();
AsyncDeleter::Element *element = realDeleteElements.front();
GuiElement *element = realDeleteElements.front();
realDeleteElements.pop();
deleteMutex.unlock();

View File

@ -18,17 +18,16 @@
#define _ASYNC_DELETER_H
#include <queue>
#include <gui/gui.h>
#include "CThread.h"
#include "CMutex.h"
class AsyncDeleter : public CThread {
public:
static void destroyInstance() {
if(deleterInstance != NULL) {
delete deleterInstance;
deleterInstance = NULL;
}
}
class Element {
public:
@ -36,27 +35,13 @@ public:
virtual ~Element() {}
};
static void pushForDelete(AsyncDeleter::Element *e) {
if(!deleterInstance) {
deleterInstance = new AsyncDeleter();
}
static void pushForDelete(GuiElement *e) {
if(!deleterInstance)
deleterInstance = new AsyncDeleter;
deleterInstance->deleteElements.push(e);
}
static BOOL deleteListEmpty() {
if(!deleterInstance) {
return true;
}
return deleterInstance->deleteElements.empty();
}
static BOOL realListEmpty() {
if(!deleterInstance) {
return true;
}
return deleterInstance->realDeleteElements.empty();
}
static void triggerDeleteProcess(void);
private:
@ -67,9 +52,9 @@ private:
void executeThread(void);
BOOL exitApplication;
std::queue<AsyncDeleter::Element *> deleteElements;
std::queue<AsyncDeleter::Element *> realDeleteElements;
bool exitApplication;
std::queue<GuiElement *> deleteElements;
std::queue<GuiElement *> realDeleteElements;
CMutex deleteMutex;
};