Skip to content

Commit

Permalink
QtBiomeVisualiser: Added quick shutdown to region loaders.
Browse files Browse the repository at this point in the history
Now the app shuts down immediately even if regions are queued for loading.
  • Loading branch information
madmaxoft committed Oct 28, 2014
1 parent 3168a95 commit 48ac3ac
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Tools/QtBiomeVisualiser/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "src/StringCompression.h"
#include "src/WorldStorage/FastNBT.h"
#include "GeneratorSetup.h"
#include "RegionLoader.h"



Expand Down Expand Up @@ -70,7 +71,7 @@ MainWindow::MainWindow(QWidget * parent) :

MainWindow::~MainWindow()
{

RegionLoader::shutdown();
}


Expand Down
10 changes: 10 additions & 0 deletions Tools/QtBiomeVisualiser/RegionLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@



volatile bool RegionLoader::m_IsShuttingDown = false;





RegionLoader::RegionLoader(int a_RegionX, int a_RegionZ, RegionPtr a_Region, ChunkSourcePtr a_ChunkSource) :
m_RegionX(a_RegionX),
m_RegionZ(a_RegionZ),
Expand All @@ -27,6 +33,10 @@ void RegionLoader::run()
for (int x = 0; x < 32; x++)
{
m_ChunkSource->getChunkBiomes(m_RegionX * 32 + x, m_RegionZ * 32 + z, m_Region->getRelChunk(x, z));
if (m_IsShuttingDown)
{
return;
}
}
}
m_Region->m_IsValid = true;
Expand Down
6 changes: 6 additions & 0 deletions Tools/QtBiomeVisualiser/RegionLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ class RegionLoader :
RegionLoader(int a_RegionX, int a_RegionZ, RegionPtr a_Region, ChunkSourcePtr a_ChunkSource);
virtual ~RegionLoader() {}

/** Signals to all loaders that the app is shutting down and the loading should be aborted. */
static void shutdown() { m_IsShuttingDown = true; }

signals:
void loaded(int a_RegionX, int a_RegionZ);

Expand All @@ -43,6 +46,9 @@ class RegionLoader :

/** The chunk source to be used for individual chunks within the region. */
ChunkSourcePtr m_ChunkSource;

/** Flag that is set upon app exit to terminate the queued loaders faster. */
static volatile bool m_IsShuttingDown;
};


Expand Down

0 comments on commit 48ac3ac

Please sign in to comment.