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 *.elf
*.exe *.exe
src/resources/filelist.h 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 # list of directories containing libraries, this must be the top level
# containing include and lib # 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 # 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 "resources/Resources.h"
#include "gui/sounds/SoundHandler.hpp" #include "gui/sounds/SoundHandler.hpp"
#include "system/memory.h" #include "system/memory.h"
#include "system/AsyncDeleter.h"
#include "utils/logger.h" #include "utils/logger.h"
Application *Application::applicationInstance = NULL; Application *Application::applicationInstance = NULL;

View File

@ -14,6 +14,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/ ****************************************************************************/
#include <coreinit/time.h>
#include "Pipe.h" #include "Pipe.h"
#include "gui/GuiTrigger.h" #include "gui/GuiTrigger.h"
#include "gui/GuiController.h" #include "gui/GuiController.h"

View File

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

View File

@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/ ****************************************************************************/
#include <system/AsyncDeleter.h> #include "AsyncDeleter.h"
AsyncDeleter * AsyncDeleter::deleterInstance = NULL; AsyncDeleter * AsyncDeleter::deleterInstance = NULL;
@ -28,9 +28,8 @@ AsyncDeleter::~AsyncDeleter() {
} }
void AsyncDeleter::triggerDeleteProcess(void) { void AsyncDeleter::triggerDeleteProcess(void) {
if(!deleterInstance){ if(!deleterInstance)
return; deleterInstance = new AsyncDeleter;
}
//! to trigger the event after GUI process is finished execution //! to trigger the event after GUI process is finished execution
//! this function is used to swap elements from one to next array //! this function is used to swap elements from one to next array
@ -46,13 +45,14 @@ void AsyncDeleter::triggerDeleteProcess(void) {
} }
void AsyncDeleter::executeThread(void) { void AsyncDeleter::executeThread(void) {
while(!exitApplication || !realDeleteElements.empty()) { while(!exitApplication) {
if(realDeleteElements.empty()) suspendThread(); suspendThread();
//! delete elements that require post process deleting //! delete elements that require post process deleting
//! because otherwise they would block or do invalid access on GUI thread //! because otherwise they would block or do invalid access on GUI thread
while(!realDeleteElements.empty()) { while(!realDeleteElements.empty()) {
deleteMutex.lock(); deleteMutex.lock();
AsyncDeleter::Element *element = realDeleteElements.front(); GuiElement *element = realDeleteElements.front();
realDeleteElements.pop(); realDeleteElements.pop();
deleteMutex.unlock(); deleteMutex.unlock();

View File

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