Skip to content
Permalink
Browse files

thread locking removed

  • Loading branch information
pka committed Aug 19, 2010
1 parent 4e0f17a commit 0fd86612e1c51cd3e9d504ec2b3fea3ef204ed87
@@ -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()),
@@ -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;
}
@@ -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);
@@ -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();

@@ -9,7 +9,6 @@ class QgisInterface;

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

using namespace osgEarth;

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

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

private:

int configureMapRender( const QPaintDevice* paintDevice ) const;
@@ -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

0 comments on commit 0fd8661

Please sign in to comment.
You can’t perform that action at this time.