mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
fixed file remove bug that crashed the application
git-svn-id: http://svn.osgeo.org/qgis/trunk@356 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
19859020d2
commit
210039baad
@ -124,10 +124,9 @@ bool QgsShapeFile::insertLayer(QString dbname, QString srid, PgDatabase * conn,
|
||||
if(n < column_names.size() -1)
|
||||
query += ", ";
|
||||
}
|
||||
query += ")";
|
||||
|
||||
query += ")";
|
||||
conn->ExecTuplesOk((const char *)query);
|
||||
|
||||
|
||||
query = "SELECT AddGeometryColumn(\'" + dbname + "\', \'" + table + "\', \'the_geom\', " + srid +
|
||||
", \'" + QString(geom_type) + "\', 2)";
|
||||
conn->ExecTuplesOk((const char *)query);
|
||||
@ -151,6 +150,7 @@ bool QgsShapeFile::insertLayer(QString dbname, QString srid, PgDatabase * conn,
|
||||
|
||||
conn->ExecTuplesOk((const char *)query);
|
||||
|
||||
pro->setProgress(pro->progress()+1);
|
||||
delete[] geo_temp;
|
||||
}
|
||||
|
||||
|
@ -140,12 +140,12 @@ void QgsSpit::removeFile()
|
||||
QListViewItemIterator it(lstShapefiles);
|
||||
while(it.current())
|
||||
if ( it.current()->isSelected() ){
|
||||
for(std::vector<QgsShapeFile *>::iterator vit = fileList.begin(); vit!=fileList.end(); vit++)
|
||||
for(std::vector<QgsShapeFile *>::iterator vit = fileList.begin(); vit!=fileList.end(); vit++){
|
||||
if((*vit)->getName()==(const char *)it.current()->text(0)){
|
||||
//QgsShapeFile *temp_it = *vit;
|
||||
fileList.erase(vit);
|
||||
//delete temp_it;
|
||||
break;
|
||||
}
|
||||
}
|
||||
delete it.current();
|
||||
it = lstShapefiles->firstChild();
|
||||
}
|
||||
@ -190,6 +190,7 @@ void QgsSpit::helpInfo(){
|
||||
|
||||
void QgsSpit::import(){
|
||||
QString connName = cmbConnections->currentText();
|
||||
bool error = false;
|
||||
if (!connName.isEmpty()) {
|
||||
QSettings settings;
|
||||
QString key = "/Qgis/connections/" + connName;
|
||||
@ -198,20 +199,28 @@ void QgsSpit::import(){
|
||||
PgDatabase *pd = new PgDatabase((const char *) connInfo);
|
||||
|
||||
if (pd->Status() == CONNECTION_OK) {
|
||||
QProgressDialog * pro = new QProgressDialog("Importing files", "Cancel", 10000, this, "Progress");
|
||||
QProgressDialog * pro = new QProgressDialog("Importing files", "Cancel", total_features, this, "Progress");
|
||||
pro->setAutoClose(true);
|
||||
pro->setAutoReset(true);
|
||||
pro->show();
|
||||
|
||||
//pd->ExecTuplesOk("BEGIN");
|
||||
pd->ExecTuplesOk("BEGIN");
|
||||
for(int i=0; i<fileList.size(); i++){
|
||||
std::stringstream temp;
|
||||
temp << spinSrid->value();
|
||||
if(!fileList[i]->insertLayer(settings.readEntry(key + "/database"), QString(temp.str()), pd, pro, total_features)){
|
||||
QMessageBox::warning(this, "Import Shapefiles", "Problem executing SQL query");
|
||||
pd->ExecTuplesOk("ROLLBACK");
|
||||
QMessageBox::warning(this, "Import Shapefiles", "Problem inserting features");
|
||||
error = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(error)
|
||||
pd->ExecCommandOk("ROLLBACK");
|
||||
else{
|
||||
int temp = pd->ExecCommandOk("COMMIT");
|
||||
std::cout<<"commit " << temp << " " << pd->ErrorMessage() << std::endl;
|
||||
}
|
||||
}
|
||||
else
|
||||
QMessageBox::warning(this, "Import Shapefiles", "Connection failed - Check settings and try again");
|
||||
|
@ -149,28 +149,6 @@
|
||||
<string>SRID</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QSpinBox">
|
||||
<property name="name">
|
||||
<cstring>spinSrid</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>140</x>
|
||||
<y>70</y>
|
||||
<width>110</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="maxValue">
|
||||
<number>1000000</number>
|
||||
</property>
|
||||
<property name="minValue">
|
||||
<number>-1</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>-1</number>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QListView">
|
||||
<column>
|
||||
<property name="text">
|
||||
@ -242,6 +220,28 @@
|
||||
<string>Add ...</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QSpinBox">
|
||||
<property name="name">
|
||||
<cstring>spinSrid</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>140</x>
|
||||
<y>70</y>
|
||||
<width>110</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="maxValue">
|
||||
<number>1000000</number>
|
||||
</property>
|
||||
<property name="minValue">
|
||||
<number>-1</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>-1</number>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QPushButton" row="2" column="1">
|
||||
<property name="name">
|
||||
@ -253,10 +253,10 @@
|
||||
</widget>
|
||||
<widget class="QPushButton" row="2" column="2">
|
||||
<property name="name">
|
||||
<cstring>btnCancel</cstring>
|
||||
<cstring>btnQuit</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Cancel</string>
|
||||
<string>Quit</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" row="2" column="4">
|
||||
@ -358,7 +358,7 @@
|
||||
<slot>editConnection()</slot>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>btnCancel</sender>
|
||||
<sender>btnQuit</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>QgsSpitBase</receiver>
|
||||
<slot>close()</slot>
|
||||
|
Loading…
x
Reference in New Issue
Block a user