Skip to content

Commit

Permalink
thread locking removed
Browse files Browse the repository at this point in the history
  • Loading branch information
pka committed Jul 5, 2011
1 parent 4e0f17a commit 0fd8661
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 35 deletions.
28 changes: 2 additions & 26 deletions src/plugins/globe/globe_plugin.cpp
Expand Up @@ -106,10 +106,6 @@ void GlobePlugin::initGui()
mQGisIface->addPluginToMenu( tr( "&Globe" ), mQActionPointer );
mQDockWidget.setWidget(&viewer);

connect(mQGisIface->mapCanvas(), SIGNAL(renderStarting()),
this, SLOT( renderStarting() ) );
connect(mQGisIface->mapCanvas(), SIGNAL(renderComplete( QPainter * )),
this, SLOT( renderComplete( QPainter * ) ) );
connect(mQGisIface->mapCanvas() , SIGNAL(extentsChanged()),
this, SLOT( extentsChanged() ) );
connect(mQGisIface->mapCanvas(), SIGNAL(layersChanged()),
Expand All @@ -128,7 +124,7 @@ void GlobePlugin::run()

// read base layers from earth file
EarthFile earthFile;
if ( !earthFile.readXML( "/home/pi/devel/gis/qgis/qgis/src/plugins/globe/globe.earth" ) )
if ( !earthFile.readXML( "/home/pi/devel/gis/qgis/src/plugins/globe/globe.earth" ) )
{
return;
}
Expand Down Expand Up @@ -168,36 +164,16 @@ void GlobePlugin::extentsChanged()
QgsDebugMsg(">>>>>>>>>> extentsChanged: " + mQGisIface->mapCanvas()->extent().toString());
}

void GlobePlugin::renderStarting()
{
if (mTileSource && mMapNode->getMap()->getImageMapLayers().size() > 1 ) { mTileSource->getRenderMutex().writeLock(); }
QgsDebugMsg(">>>>>>>>>> renderStarting");
}

void GlobePlugin::renderComplete( QPainter * )
{
if (mTileSource && mMapNode->getMap()->getImageMapLayers().size() > 1) { mTileSource->getRenderMutex().writeUnlock(); }
QgsDebugMsg(">>>>>>>>>> renderComplete");
}

void GlobePlugin::layersChanged()
{
QgsDebugMsg(">>>>>>>>>> layersChanged");
if (mTileSource && mMapNode->getMap()->getImageMapLayers().size() > 1)
{
{
Threading::ScopedReadLock lock(mTileSource->getRenderMutex());
viewer.getDatabasePager()->clear();
}
viewer.getDatabasePager()->clear();
QgsDebugMsg(">>>>>>>>>> removeMapLayer");
QgsDebugMsg(QString(">>>>>>>>>> getImageMapLayers().size = %1").arg(mMapNode->getMap()->getImageMapLayers().size() ));
mMapNode->getMap()->removeMapLayer( mQgisMapLayer );
QgsDebugMsg(QString(">>>>>>>>>> getImageMapLayers().size = %1").arg(mMapNode->getMap()->getImageMapLayers().size() ));
//QgsDebugMsg(">>>>>>>>>> addMapLayer");
//mMapNode->getMap()->addMapLayer( mQgisMapLayer );
//QgsDebugMsg(QString(">>>>>>>>>> getImageMapLayers().size = %1").arg(mMapNode->getMap()->getImageMapLayers().size() ));
} else if (mTileSource && mMapNode->getMap()->getImageMapLayers().size() == 1)
{
QgsDebugMsg(">>>>>>>>>> addMapLayer");
mTileSource = new QgsOsgEarthTileSource(mQGisIface);
mTileSource->initialize("", 0);
Expand Down
5 changes: 1 addition & 4 deletions src/plugins/globe/qgsosgearthtilesource.cpp
Expand Up @@ -89,10 +89,7 @@ osg::Image* QgsOsgEarthTileSource::createImage( const TileKey* key,

QPainter thePainter(qImage);
//thePainter.setRenderHint(QPainter::Antialiasing); //make it look nicer
{
Threading::ScopedReadLock lock(mRenderMutex);
mMapRenderer->render(&thePainter);
}
mMapRenderer->render(&thePainter);

unsigned char* data = qImage->bits();

Expand Down
5 changes: 0 additions & 5 deletions src/plugins/globe/qgsosgearthtilesource.h
Expand Up @@ -9,7 +9,6 @@ class QgisInterface;

#include <osgEarth/Common>
#include <osgEarth/TileSource>
#include <osgEarth/ThreadingUtils>

using namespace osgEarth;

Expand Down Expand Up @@ -44,8 +43,6 @@ namespace osgEarth { namespace Drivers
return false;
}

Threading::ReadWriteMutex& getRenderMutex() { return mRenderMutex; }

private:

int configureMapRender( const QPaintDevice* paintDevice ) const;
Expand All @@ -55,8 +52,6 @@ namespace osgEarth { namespace Drivers
//! Pointer to the QGIS interface object
QgisInterface *mQGisIface;
QgsMapRenderer* mMapRenderer;
//! Canvas render Mutex
Threading::ReadWriteMutex mRenderMutex;

};
} } // namespace osgEarth::Drivers
Expand Down

0 comments on commit 0fd8661

Please sign in to comment.