Skip to content

Commit

Permalink
Enable backbuffering / incremental drawing features only on supported…
Browse files Browse the repository at this point in the history
… platforms

Correct typo
  • Loading branch information
m-kuhn authored and mhugent committed Aug 9, 2012
1 parent 295c464 commit 02f06f9
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 7 deletions.
14 changes: 12 additions & 2 deletions src/app/qgsoptions.cpp
Expand Up @@ -76,8 +76,9 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
connect( spinFontSize, SIGNAL( valueChanged( const QString& ) ), this, SLOT( fontSizeChanged( const QString& ) ) );

connect( chkUseStandardDeviation, SIGNAL( stateChanged( int ) ), this, SLOT( toggleStandardDeviation( int ) ) );

#ifdef Q_WS_X11
connect( chkEnableBackbuffer, SIGNAL( stateChanged( int ) ), this, SLOT( toggleEnableBackbuffer( int ) ) );
#endif

connect( this, SIGNAL( accepted() ), this, SLOT( saveOptions() ) );

Expand Down Expand Up @@ -229,10 +230,19 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
if ( index == -1 ) index = 1;
cmbScanZipInBrowser->setCurrentIndex( index );

// Set the enable backbuffer state
// Set the enable backbuffer state for X11 (linux) systems only
// TODO: remove this when threading is implemented
#ifdef Q_WS_X11
chkEnableBackbuffer->setChecked( settings.value( "/Map/enableBackbuffer" ).toBool() );
toggleEnableBackbuffer( chkEnableBackbuffer->checkState() );
#elif Q_WS_MAC
chkEnableBackbuffer->setChecked( true );
chkEnableBackbuffer->setEnabled( false );
labelUpdateThreshold->setEnabled( false );
spinBoxUpdateThreshold->setEnabled( false );
#else // Q_WS_WIN32
chkEnableBackbuffer->setChecked( true );
chkEnableBackbuffer->setEnabled( false );
#endif

// set the display update threshold
Expand Down
2 changes: 2 additions & 0 deletions src/app/qgsoptions.h
Expand Up @@ -74,9 +74,11 @@ class QgsOptions : public QDialog, private Ui::QgsOptionsBase

void toggleStandardDeviation( int );

#ifdef Q_WS_X11
//! Slot to change backbuffering. This is handled when the user changes
// the value of the checkbox
void toggleEnableBackbuffer( int );
#endif

/**
* Return the desired state of newly added layers. If a layer
Expand Down
6 changes: 5 additions & 1 deletion src/core/qgsvectorlayer.cpp
Expand Up @@ -734,8 +734,10 @@ void QgsVectorLayer::drawRendererV2( QgsRenderContext& rendererContext, bool lab
break;
}
#ifndef Q_WS_MAC //MH: disable this on Mac for now to avoid problems with resizing
#ifdef Q_WS_X11
if ( !mEnableBackbuffer ) // do not handle events, as we're already inside a paint event
{
#endif // Q_WS_X11
if ( mUpdateThreshold > 0 && 0 == featureCount % mUpdateThreshold )
{
emit screenUpdateRequested();
Expand All @@ -747,8 +749,10 @@ void QgsVectorLayer::drawRendererV2( QgsRenderContext& rendererContext, bool lab
// emit drawingProgress( featureCount, totalFeatures );
qApp->processEvents();
}
#ifdef Q_WS_X11
}
#endif //Q_WS_MAC
#endif // Q_WS_X11
#endif // Q_WS_MAC

bool sel = mSelectedFeatureIds.contains( fet.id() );
bool drawMarker = ( mEditable && ( !vertexMarkerOnlyForSelection || sel ) );
Expand Down
8 changes: 5 additions & 3 deletions src/gui/qgsmapcanvas.cpp
Expand Up @@ -377,10 +377,11 @@ void QgsMapCanvas::refresh()
bool enableBackbufferSetting = 0;
#endif

//disable the update that leads to the resize crash
#ifdef Q_WS_X11
#ifndef ANDROID
// disable the update that leads to the resize crash on X11 systems
if ( viewport() )
{
#ifndef ANDROID
if ( enableBackbufferSetting != mBackbufferEnabled )
{
qDebug() << "Enable back buffering: " << enableBackbufferSetting;
Expand All @@ -394,8 +395,9 @@ void QgsMapCanvas::refresh()
}
mBackbufferEnabled = enableBackbufferSetting;
}
#endif //ANDROID
}
#endif // ANDROID
#endif // Q_WS_X11

mDrawing = true;

Expand Down
2 changes: 1 addition & 1 deletion src/ui/qgsoptionsbase.ui
Expand Up @@ -977,7 +977,7 @@
<item row="2" column="0">
<widget class="QCheckBox" name="chkEnableBackbuffer">
<property name="text">
<string>Enable back buffer (Better graphics performance at the cost loosing the possibiliti to cancel rendering and incremental feature drawing)</string>
<string>Enable back buffer (Better graphics performance at the cost of loosing the possibility to cancel rendering and incremental feature drawing)</string>
</property>
</widget>
</item>
Expand Down

0 comments on commit 02f06f9

Please sign in to comment.