Skip to content

Commit

Permalink
fix crash
Browse files Browse the repository at this point in the history
  • Loading branch information
mehah committed Dec 30, 2023
1 parent 5fd911b commit be63cd8
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 20 deletions.
13 changes: 6 additions & 7 deletions src/framework/core/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ void Application::deinit()

// disable dispatcher events
g_textDispatcher.shutdown();
g_dispatcher.shutdown();
g_dispatcher.shutdown();
g_mainDispatcher.shutdown();

// run modules unload events
Expand Down Expand Up @@ -145,13 +145,17 @@ void Application::terminate()

void Application::poll()
{
std::scoped_lock l(g_drawPool.get(DrawPoolType::FOREGROUND_MAP)->getMutexPreDraw());
g_clock.update();

#ifdef FRAMEWORK_NET
Connection::poll();
#endif

dispatchPoll();
{
std::scoped_lock l(g_drawPool.get(DrawPoolType::FOREGROUND)->getMutexPreDraw());
g_dispatcher.poll();
}

// poll connection again to flush pending write
#ifdef FRAMEWORK_NET
Expand All @@ -161,11 +165,6 @@ void Application::poll()
g_clock.update();
}

void Application::dispatchPoll()
{
g_dispatcher.poll();
}

void Application::exit()
{
g_lua.callGlobalField<bool>("g_app", "onExit");
Expand Down
3 changes: 1 addition & 2 deletions src/framework/core/application.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class ApplicationContext
uint8_t m_asyncDispatchMaxThreads;
};

//@bindsingleton g_app
//@bindsingleton g_app
class Application
{
public:
Expand All @@ -48,7 +48,6 @@ class Application
virtual void terminate();
virtual void run() = 0;
virtual void poll();
virtual void dispatchPoll();
virtual void exit();
virtual void close();
virtual void restart();
Expand Down
9 changes: 0 additions & 9 deletions src/framework/core/graphicalapplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,15 +269,6 @@ void GraphicalApplication::poll()
g_textDispatcher.poll();
}
}

void GraphicalApplication::dispatchPoll()
{
std::scoped_lock l(g_drawPool.get(DrawPoolType::FOREGROUND)->getMutexPreDraw(),
g_drawPool.get(DrawPoolType::FOREGROUND_MAP)->getMutexPreDraw());

Application::dispatchPoll();
}

void GraphicalApplication::mainPoll()
{
g_clock.update();
Expand Down
3 changes: 1 addition & 2 deletions src/framework/core/graphicalapplication.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ class GraphicalApplication : public Application
void terminate() override;
void run() override;
void poll() override;
void dispatchPoll() override;
void mainPoll();
void close() override;

Expand All @@ -95,7 +94,7 @@ class GraphicalApplication : public Application
#else
return false;
#endif
}
}
bool isForcedEffectOptimization() { return m_forceEffectOptimization; }

void optimize(const bool optimize) { m_optimize = optimize; }
Expand Down

2 comments on commit be63cd8

@BenDol
Copy link
Collaborator

@BenDol BenDol commented on be63cd8 Jan 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This adds graphical code to the base Application class and breaks any non-graphical implementations of Application (in my case ConsoleApplication)

EDIT: We could macro #ifdef FRAMEWORK_GRAPHICS if we can't add this functionality to GraphicalApplication (where it belongs). Not sure what is causing the crash here.

@mehah
Copy link
Owner Author

@mehah mehah commented on be63cd8 Jan 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BenDol
apparently there were already problems, several errors occurred without the FRAMEWORK_GRAPHICS macro
image

Please sign in to comment.