Skip to content
Permalink
Browse files

Merge pull request #8662 from elpaso/elpaso-backport-3_4

Weekly backports to 3.4
  • Loading branch information
elpaso committed Dec 13, 2018
2 parents 7fd6a20 + 6f725b8 commit 91fcb799f7ce4c501954268c7cbd88f1d2b184eb
@@ -147,13 +147,13 @@ def __init__(self, iface, layer, parent=None):

# Update from layer
# First the SQL from QgsDataSourceUri table
sql = uri.table()
sql = uri.table().replace('\n', ' ').strip()
if uri.keyColumn() == '_uid_':
match = re.search(r'^\(SELECT .+ AS _uid_,\* FROM \((.*)\) AS _subq_.+_\s*\)$', sql, re.S | re.X)
match = re.search(r'^\(SELECT .+ AS _uid_,\* FROM \((.*)\) AS _subq_.+_\s*\)$', sql, re.S | re.X | re.IGNORECASE)
if match:
sql = match.group(1)
else:
match = re.search(r'^\((SELECT .+ FROM .+)\)$', sql, re.S | re.X)
match = re.search(r'^\((SELECT .+ FROM .+)\)$', sql, re.S | re.X | re.IGNORECASE)
if match:
sql = match.group(1)
# Need to check on table() since the parentheses were removed by the regexp
@@ -561,7 +561,7 @@ def createView(self):
def _getSqlQuery(self):
sql = self.editSql.selectedText()
if len(sql) == 0:
sql = self.editSql.text()
sql = self.editSql.text().replace('\n', ' ').strip()
return sql

def uniqueChanged(self):
@@ -1086,32 +1086,48 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QList<QgsOpti

#ifdef HAVE_OPENCL

// Setup OpenCL (GPU) widget
mGPUEnableCheckBox->setChecked( QgsOpenClUtils::enabled( ) );
if ( QgsOpenClUtils::available( ) )
{
mGPUEnableCheckBox->setEnabled( true );
// Setup OpenCL Acceleration widget

for ( const auto &dev : QgsOpenClUtils::devices( ) )
connect( mGPUEnableCheckBox, &QCheckBox::toggled, [ = ]( bool checked )
{
if ( checked )
{
mOpenClDevicesCombo->addItem( QgsOpenClUtils::deviceInfo( QgsOpenClUtils::Info::Name, dev ), QgsOpenClUtils::deviceId( dev ) );
if ( QgsOpenClUtils::available( ) )
{
mOpenClContainerWidget->setEnabled( true );
mOpenClDevicesCombo->clear();

for ( const auto &dev : QgsOpenClUtils::devices( ) )
{
mOpenClDevicesCombo->addItem( QgsOpenClUtils::deviceInfo( QgsOpenClUtils::Info::Name, dev ), QgsOpenClUtils::deviceId( dev ) );
}
// Info updater
std::function<void( int )> infoUpdater = [ = ]( int )
{
mGPUInfoTextBrowser->setText( QgsOpenClUtils::deviceDescription( mOpenClDevicesCombo->currentData().toString() ) );
};
connect( mOpenClDevicesCombo, qgis::overload< int >::of( &QComboBox::currentIndexChanged ), infoUpdater );
mOpenClDevicesCombo->setCurrentIndex( mOpenClDevicesCombo->findData( QgsOpenClUtils::deviceId( QgsOpenClUtils::activeDevice() ) ) );
infoUpdater( -1 );
mOpenClContainerWidget->show();
}
else
{
mGPUInfoTextBrowser->setText( tr( "No OpenCL compatible devices were found on your system.<br>"
"You may need to install additional libraries in order to enable OpenCL.<br>"
"Please check your logs for further details." ) );
mOpenClContainerWidget->setEnabled( false );
mGPUEnableCheckBox->setChecked( false );
}
}
// Info updater
std::function<void( int )> infoUpdater = [ = ]( int )
else
{
mGPUInfoTextBrowser->setText( QgsOpenClUtils::deviceDescription( mOpenClDevicesCombo->currentData().toString() ) );
};
connect( mOpenClDevicesCombo, qgis::overload< int >::of( &QComboBox::currentIndexChanged ), infoUpdater );
mOpenClDevicesCombo->setCurrentIndex( mOpenClDevicesCombo->findData( QgsOpenClUtils::deviceId( QgsOpenClUtils::activeDevice() ) ) );
infoUpdater( -1 );
}
else
{
mGPUEnableCheckBox->setEnabled( false );
mGPUInfoTextBrowser->setText( tr( "An OpenCL compatible device was not found on your system.<br>"
"You may need to install additional libraries in order to enable OpenCL.<br>"
"Please check your logs for further details." ) );
}
mOpenClContainerWidget->setEnabled( false );
}
} );

mOpenClContainerWidget->setEnabled( false );
mGPUEnableCheckBox->setChecked( QgsOpenClUtils::enabled( ) );


#else
@@ -34,6 +34,8 @@ void QgsReadWriteLocker::changeMode( QgsReadWriteLocker::Mode mode )

unlock();

mMode = mode;

if ( mMode == Read )
mLock.lockForRead();
else if ( mMode == Write )
@@ -110,7 +110,7 @@ bool QgsZipUtils::unzip( const QString &zipFilename, const QString &dir, QString
}
else
{
QString err = QObject::tr( "Error opening zip archive: '%1'" ).arg( zip_strerror( z ) );
QString err = QObject::tr( "Error opening zip archive: '%1'" ).arg( z ? zip_strerror( z ) : zipFilename );
QgsMessageLog::logMessage( err, QStringLiteral( "QgsZipUtils" ) );
return false;
}
@@ -4603,9 +4603,21 @@ bool QgsSpatiaLiteProvider::checkLayerType()
// 3. check if ROWID injection works
if ( ! queryGeomTableName.isEmpty() )
{
// Check if the whole sql is aliased (I couldn't find a sqlite API call to get this information)
QRegularExpression re { R"re(\s+AS\s+(\w+)\n?\)?$)re" };
re.setPatternOptions( QRegularExpression::PatternOption::MultilineOption |
QRegularExpression::PatternOption::CaseInsensitiveOption );
QRegularExpressionMatch match { re.match( mTableName ) };
regex.setPattern( QStringLiteral( R"re(\s+AS\s+(\w+)\n?\)?$)re" ) );
QString tableAlias;
if ( match.hasMatch() )
{
tableAlias = match.captured( 1 );
}
QString newSql( mQuery.replace( QStringLiteral( "SELECT " ),
QStringLiteral( "SELECT %1.%2, " )
.arg( quotedIdentifier( queryGeomTableName ), QStringLiteral( "ROWID" ) ),
.arg( quotedIdentifier( tableAlias.isEmpty() ? queryGeomTableName : tableAlias ),
QStringLiteral( "ROWID" ) ),
Qt::CaseInsensitive ) );
sql = QStringLiteral( "SELECT ROWID FROM %1 WHERE ROWID IS NOT NULL LIMIT 1" ).arg( newSql );
ret = sqlite3_get_table( mSqliteHandle, sql.toUtf8().constData(), &results, &rows, &columns, &errMsg );
@@ -332,7 +332,7 @@
<item>
<widget class="QStackedWidget" name="mOptionsStackedWidget">
<property name="currentIndex">
<number>0</number>
<number>16</number>
</property>
<widget class="QWidget" name="mOptionsPageGeneral">
<layout class="QVBoxLayout" name="verticalLayout_3">
@@ -1083,7 +1083,7 @@
<x>0</x>
<y>0</y>
<width>544</width>
<height>1096</height>
<height>1095</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_22">
@@ -3216,7 +3216,7 @@
<x>0</x>
<y>0</y>
<width>613</width>
<height>646</height>
<height>641</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_30">
@@ -3659,7 +3659,7 @@ The bigger the number, the faster zooming with the mouse wheel will be.</string>
<rect>
<x>0</x>
<y>0</y>
<width>154</width>
<width>153</width>
<height>271</height>
</rect>
</property>
@@ -4867,8 +4867,8 @@ The bigger the number, the faster zooming with the mouse wheel will be.</string>
<rect>
<x>0</x>
<y>0</y>
<width>857</width>
<height>828</height>
<width>616</width>
<height>736</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_33">
@@ -5332,31 +5332,49 @@ The bigger the number, the faster zooming with the mouse wheel will be.</string>
</widget>
</item>
<item>
<widget class="QLabel" name="label_64">
<widget class="QCheckBox" name="mGPUEnableCheckBox">
<property name="text">
<string>The following OpenCL devices were found on this system (changing the default device requires QGIS to be restarted).</string>
<string>Enable OpenCL acceleration</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="mOpenClDevicesCombo"/>
</item>
<item>
<widget class="QTextBrowser" name="mGPUInfoTextBrowser">
<property name="html">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
<widget class="QWidget" name="mOpenClContainerWidget" native="true">
<layout class="QVBoxLayout" name="verticalLayout_32">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label_64">
<property name="text">
<string>The following OpenCL devices were found on this system (changing the default device requires QGIS to be restarted).</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="mOpenClDevicesCombo"/>
</item>
<item>
<widget class="QTextBrowser" name="mGPUInfoTextBrowser">
<property name="html">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Noto Sans'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Placemark for OpenCL information results (mGPUInfoTextBrowser)&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="mGPUEnableCheckBox">
<property name="text">
<string>Enable OpenCL acceleration</string>
</property>
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Noto Sans'; font-size:10pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
@@ -5743,12 +5761,40 @@ p, li { white-space: pre-wrap; }
<tabstop>mRemoveUrlPushButton</tabstop>
<tabstop>mExcludeUrlListWidget</tabstop>
<tabstop>mAdvancedSettingsEnableButton</tabstop>
<tabstop>mOpenClDevicesCombo</tabstop>
<tabstop>mGPUInfoTextBrowser</tabstop>
<tabstop>mGPUEnableCheckBox</tabstop>
</tabstops>
<resources>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
</resources>
<connections>
<connection>

0 comments on commit 91fcb79

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