File tree Expand file tree Collapse file tree 4 files changed +30
-5
lines changed Expand file tree Collapse file tree 4 files changed +30
-5
lines changed Original file line number Diff line number Diff line change @@ -136,6 +136,13 @@ class QgsProjectArchive : QgsArchive
136
136
Returns the current .qgs project file or an empty string if there's none
137
137
:rtype: str
138
138
%End
139
+
140
+ bool clearProjectFile();
141
+ %Docstring
142
+ Remove the current .qgs project file from the temporary directory.
143
+ :return: true if the file is well removed, false otherwise
144
+ :rtype: bool
145
+ %End
139
146
};
140
147
141
148
/************************************************************************
Original file line number Diff line number Diff line change @@ -152,3 +152,17 @@ bool QgsProjectArchive::unzip( const QString &filename )
152
152
else
153
153
return false ;
154
154
}
155
+
156
+ bool QgsProjectArchive::clearProjectFile ()
157
+ {
158
+ bool rc = false ;
159
+ QString file = projectFile ();
160
+
161
+ if ( !file.isEmpty () && QFile::exists ( file ) )
162
+ rc = QFile::remove ( file );
163
+
164
+ if ( rc )
165
+ mFiles .removeOne ( file );
166
+
167
+ return rc;
168
+ }
Original file line number Diff line number Diff line change @@ -147,6 +147,12 @@ class CORE_EXPORT QgsProjectArchive : public QgsArchive
147
147
* Returns the current .qgs project file or an empty string if there's none
148
148
*/
149
149
QString projectFile () const ;
150
+
151
+ /* *
152
+ * Remove the current .qgs project file from the temporary directory.
153
+ * \returns true if the file is well removed, false otherwise
154
+ */
155
+ bool clearProjectFile ();
150
156
};
151
157
152
158
#endif
Original file line number Diff line number Diff line change @@ -2110,17 +2110,18 @@ bool QgsProject::unzip( const QString &filename )
2110
2110
return false ;
2111
2111
}
2112
2112
2113
- // keep the archive
2113
+ // keep the archive and remove the temporary .qgs file
2114
2114
mUnzipping = false ;
2115
2115
mPathResolverBaseName = QString ();
2116
2116
mArchive .reset ( archive.release () );
2117
+ mArchive ->clearProjectFile ();
2117
2118
2118
2119
return true ;
2119
2120
}
2120
2121
2121
2122
bool QgsProject::zip ()
2122
2123
{
2123
- if ( unzipped () )
2124
+ if ( ! mArchive -> filename (). isEmpty () )
2124
2125
return zip ( mArchive ->filename () );
2125
2126
2126
2127
return false ;
@@ -2168,9 +2169,6 @@ bool QgsProject::zip( const QString &filename )
2168
2169
return false ;
2169
2170
}
2170
2171
2171
- // keep the archive
2172
- mArchive .reset ( archive.release () );
2173
-
2174
2172
return true ;
2175
2173
}
2176
2174
You can’t perform that action at this time.
0 commit comments