paysages : Fixed preview threads termination
git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@313 b1fd45b6-86a6-48da-8261-f70d1f35bdcc
This commit is contained in:
parent
943cc9418e
commit
390fb34f65
4 changed files with 83 additions and 61 deletions
|
@ -20,6 +20,7 @@ public:
|
|||
_ysize = ysize;
|
||||
|
||||
_need_render = true;
|
||||
_alive = true;
|
||||
}
|
||||
|
||||
bool isFrom(BasePreview* preview)
|
||||
|
@ -27,6 +28,11 @@ public:
|
|||
return _preview == preview;
|
||||
}
|
||||
|
||||
void interrupt()
|
||||
{
|
||||
_alive = false;
|
||||
}
|
||||
|
||||
void update()
|
||||
{
|
||||
_need_render = true;
|
||||
|
@ -48,6 +54,10 @@ public:
|
|||
for (int y = 0; y < _ysize; y++)
|
||||
{
|
||||
QRgb col = pixbuf.pixel(x, y);
|
||||
if (!_alive)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (qAlpha(col) < 255)
|
||||
{
|
||||
QColor newcol = _preview->getPixelColor(_xstart + x, _ystart + y);
|
||||
|
@ -70,6 +80,7 @@ public:
|
|||
}
|
||||
private:
|
||||
BasePreview* _preview;
|
||||
bool _alive;
|
||||
bool _need_render;
|
||||
int _xstart;
|
||||
int _ystart;
|
||||
|
@ -121,6 +132,22 @@ void PreviewDrawingManager::startThreads()
|
|||
}
|
||||
}
|
||||
|
||||
void PreviewDrawingManager::stopThreads()
|
||||
{
|
||||
for (int i = 0; i < _threads.size(); i++)
|
||||
{
|
||||
_threads.at(i)->askStop();
|
||||
}
|
||||
for (int i = 0; i < _chunks.size(); i++)
|
||||
{
|
||||
_chunks.at(i)->interrupt();
|
||||
}
|
||||
for (int i = 0; i < _threads.size(); i++)
|
||||
{
|
||||
_threads.at(i)->wait();
|
||||
}
|
||||
}
|
||||
|
||||
void PreviewDrawingManager::addChunk(PreviewChunk* chunk)
|
||||
{
|
||||
_lock.lock();
|
||||
|
@ -169,27 +196,19 @@ void PreviewDrawingManager::updateChunks(BasePreview* preview)
|
|||
void PreviewDrawingManager::performOneThreadJob()
|
||||
{
|
||||
PreviewChunk* chunk;
|
||||
do
|
||||
|
||||
chunk = NULL;
|
||||
_lock.lock();
|
||||
if (!_updateQueue.isEmpty())
|
||||
{
|
||||
chunk = NULL;
|
||||
_lock.lock();
|
||||
if (!_updateQueue.isEmpty())
|
||||
{
|
||||
chunk = _updateQueue.takeFirst();
|
||||
}
|
||||
_lock.unlock();
|
||||
|
||||
if (chunk)
|
||||
{
|
||||
chunk->render();
|
||||
PreviewDrawingThread::usleep(50000);
|
||||
}
|
||||
else
|
||||
{
|
||||
PreviewDrawingThread::usleep(50000);
|
||||
}
|
||||
|
||||
} while (true);
|
||||
chunk = _updateQueue.takeFirst();
|
||||
}
|
||||
_lock.unlock();
|
||||
|
||||
if (chunk)
|
||||
{
|
||||
chunk->render();
|
||||
}
|
||||
}
|
||||
|
||||
/*************** BasePreview ***************/
|
||||
|
@ -247,7 +266,7 @@ void BasePreview::initDrawers()
|
|||
|
||||
void BasePreview::stopDrawers()
|
||||
{
|
||||
//delete _drawing_manager;
|
||||
_drawing_manager->stopThreads();
|
||||
}
|
||||
|
||||
void BasePreview::updateData()
|
||||
|
|
|
@ -108,6 +108,7 @@ class PreviewDrawingManager {
|
|||
public:
|
||||
PreviewDrawingManager();
|
||||
void startThreads();
|
||||
void stopThreads();
|
||||
void addChunk(PreviewChunk* chunk);
|
||||
void removeChunks(BasePreview* preview);
|
||||
void updateChunks(BasePreview* preview);
|
||||
|
|
|
@ -60,6 +60,8 @@ int main(int argc, char** argv)
|
|||
|
||||
result = app.exec();
|
||||
|
||||
BasePreview::stopDrawers();
|
||||
|
||||
delete window;
|
||||
|
||||
paysagesQuit();
|
||||
|
|
|
@ -709,139 +709,139 @@ Maintenir Ctrl : Plus rapide</translation>
|
|||
<context>
|
||||
<name>MainWindow</name>
|
||||
<message>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="79"/>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="81"/>
|
||||
<source>Terrain</source>
|
||||
<translation>Terrain</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="83"/>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="85"/>
|
||||
<source>Textures</source>
|
||||
<translation>Textures</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="87"/>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="89"/>
|
||||
<source>Water</source>
|
||||
<translation>Eau</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="95"/>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="97"/>
|
||||
<source>Atmosphere</source>
|
||||
<translation>Atmosphère</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="121"/>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="123"/>
|
||||
<source>&Load</source>
|
||||
<translation>&Ouvrir</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="121"/>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="123"/>
|
||||
<source>Crtl+L</source>
|
||||
<translation>Ctrl+O</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="122"/>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="124"/>
|
||||
<source>&Explore (F2)</source>
|
||||
<translation>&Explorer (F2)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="122"/>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="124"/>
|
||||
<source>F2</source>
|
||||
<translation>F2</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="123"/>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="125"/>
|
||||
<source>&Quick
|
||||
render (F5)</source>
|
||||
<translation>&Rendu
|
||||
rapide (F5)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="123"/>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="125"/>
|
||||
<source>F5</source>
|
||||
<translation>F5</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="143"/>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="145"/>
|
||||
<source>Do you want to start a new scenery ? Any unsaved changes will be lost.</source>
|
||||
<translation>Voulez-vous commencer un nouveau paysage ? Les modifications non sauvegardées seront perdues.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="143"/>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="145"/>
|
||||
<source>Paysages 3D - New scenery</source>
|
||||
<translation>Paysages 3D - Nouvelle scène</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="153"/>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="155"/>
|
||||
<source>Paysages 3D - Choose a file to save the scenery</source>
|
||||
<translation>Paysages 3D - Choisissez un fichier pour enregistrer la scène</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="153"/>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="179"/>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="155"/>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="181"/>
|
||||
<source>Paysages 3D Scenery (*.p3d)</source>
|
||||
<translation>Scène Paysages 3D (*.p3d)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="167"/>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="170"/>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="169"/>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="172"/>
|
||||
<source>Paysages 3D - File saving error</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="167"/>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="169"/>
|
||||
<source>Can't write specified file : %1</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="170"/>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="172"/>
|
||||
<source>Unexpected error while saving file : %1</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="177"/>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="179"/>
|
||||
<source>Do you want to load a scenery from file ? Any unsaved changes will be lost.</source>
|
||||
<translation>Voulez-vous charger une scène ? Les modifications nons sauvegardées seront perdues.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="177"/>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="179"/>
|
||||
<source>Paysages 3D - Load scenery</source>
|
||||
<translation>Paysages 3D - Charger une scène</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="179"/>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="181"/>
|
||||
<source>Paysages 3D - Choose a scenery file to load</source>
|
||||
<translation>Paysages 3D - Choisissez un fichier de scène à charger</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="189"/>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="192"/>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="195"/>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="198"/>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="191"/>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="194"/>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="197"/>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="200"/>
|
||||
<source>Paysages 3D - File loading error</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="189"/>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="191"/>
|
||||
<source>Can't read specified file : %1</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="192"/>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="194"/>
|
||||
<source>This file doesn't look like a Paysages 3D file : %1</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="195"/>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="197"/>
|
||||
<source>This file was created with an incompatible Paysages 3D version : %1</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="198"/>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="200"/>
|
||||
<source>Unexpected error while loading file : %1</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="206"/>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="208"/>
|
||||
<source>A 3D landscape editing and rendering software.
|
||||
|
||||
Authors :
|
||||
|
@ -854,12 +854,12 @@ GLib - http://www.gtk.org/
|
|||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="91"/>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="93"/>
|
||||
<source>Sky</source>
|
||||
<translation>Ciel</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="99"/>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="101"/>
|
||||
<source>Clouds</source>
|
||||
<translation>Nuages</translation>
|
||||
</message>
|
||||
|
@ -868,7 +868,7 @@ GLib - http://www.gtk.org/
|
|||
<translation type="obsolete">Eclairage</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="107"/>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="109"/>
|
||||
<source>Render</source>
|
||||
<translation>Rendu</translation>
|
||||
</message>
|
||||
|
@ -877,22 +877,22 @@ GLib - http://www.gtk.org/
|
|||
<translation type="obsolete">&Scène</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="119"/>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="121"/>
|
||||
<source>&New</source>
|
||||
<translation>&Nouveau</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="119"/>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="121"/>
|
||||
<source>Crtl+N</source>
|
||||
<translation>Ctrl+N</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="120"/>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="122"/>
|
||||
<source>&Save</source>
|
||||
<translation>&Sauvegarder</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="120"/>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="122"/>
|
||||
<source>Crtl+S</source>
|
||||
<translation>Ctrl+S</translation>
|
||||
</message>
|
||||
|
@ -929,7 +929,7 @@ GLib - http://www.gtk.org/
|
|||
<translation type="obsolete">Ai&de</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="124"/>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="126"/>
|
||||
<source>&About</source>
|
||||
<translation>&A propos</translation>
|
||||
</message>
|
||||
|
@ -950,7 +950,7 @@ GLib - http://www.gtk.org/
|
|||
<translation type="obsolete">Voulez-vous charger un paysage ? Les modifications nons sauvegardées seront perdues.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="206"/>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="208"/>
|
||||
<source>Paysages 3D</source>
|
||||
<translation>Paysages 3D</translation>
|
||||
</message>
|
||||
|
|
Loading…
Reference in a new issue