Commit Graph

38 Commits

Author SHA1 Message Date
Eike Ziller
40f2f99714 SaveFile: Fix error handling when moving file with new contents fails
The original content is moved to a backup, then the new file is moved
into its place. If that second step fails, we have to at least try
to move the backup back into the original place, and definitely
not remove the backup.

This behavior changed in 0dafe5cb8c

Task-number: QTCREATORBUG-21724
Change-Id: I996098576c0ceed59dd7359ac4f1b9d33f87d596
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
2018-12-17 13:05:31 +00:00
Eike Ziller
6507db19e4 Merge remote-tracking branch 'origin/4.7' into 4.8
Change-Id: Ia215af4ddad73053582284d3ce8d56b92dbbc8f3
2018-09-27 09:07:07 +02:00
David Schulz
8d609692b3 Utils: Fix file saver for delete locked files
If we can not delete a file via the ReplaceFile operation, because we ca
not get the DELETE access right we still can try to replace it contents.

Task-number: QTCREATORBUG-7668
Change-Id: I8804133a0e118518307f33976b821d5b2fdc9b8d
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-09-26 10:58:11 +00:00
Alessandro Portale
f6943a712a Utils: Modernize further
Many issues, mostly in headers, were not addressed in
e38410b76c

modernize-use-auto
modernize-use-nullptr
modernize-use-override
modernize-use-using
modernize-use-default-member-init
modernize-use-equals-default

Change-Id: I320a51726db881e582b898948d53735ebb06887a
Reviewed-by: hjk <hjk@qt.io>
2018-07-24 12:21:42 +00:00
Alessandro Portale
e38410b76c Utils: Modernize
modernize-use-auto
modernize-use-nullptr
modernize-use-override
modernize-use-using
modernize-use-default-member-init
modernize-use-equals-default

Change-Id: I8d44d9405011a1878353baf9325f7af90b89db02
Reviewed-by: hjk <hjk@qt.io>
2018-07-20 13:36:22 +00:00
Orgad Shaneh
1958c2129e Revert "Windows: Match the name case of included files"
It breaks cross-compilation on linux/mingw.

This reverts commit 1c014ed3d9.

Change-Id: I3e8183ec318541a4393ad242eefbdeaa78b7be44
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2018-07-19 05:44:06 +00:00
Alessandro Portale
1c014ed3d9 Windows: Match the name case of included files
Although Windows is case insensitive, and lower case always works, Clang
complains:

Lexical or Preprocessor Issue: warning: non-portable path to file
'<FooBar.h>'; specified path differs in case from file name on disk

Change-Id: I8f94e9fb62f6afec8aa6b9d08a7c78f6ba8a4435
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2018-07-12 20:12:30 +00:00
Eike Ziller
09a761ad7b Fix issues with saving files on network drives on Windows
In these cases the user might not have sufficient rights for
ReplaceFile to merge all file attributes and ACLs.
Make ReplaceFile ignore these errors.

Task-number: QTCREATORBUG-20560
Change-Id: I6980d8af66cb7200c39726f0e7273df83c99bf5c
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2018-06-29 10:53:08 +00:00
Ivan Donchevskii
bc4efa662c Utils: fix savefile in case we save new file (Windows)
Previous fix accidently broke saving files that do not
exist yet. They need to call rename instead of ReplaceFile.

Change-Id: Ida47845a59c1f2fe26a39dc593ab0f83fae9d18b
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
2017-12-20 11:52:20 +00:00
Robert Loehning
afbb427ac5 Utils: Don't proceed with temp file which could not be opened
Change-Id: I0e12d63ecaa52e9396216c4f59e12a9ba15d9774
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2017-12-19 14:38:49 +00:00
Ivan Donchevskii
29b7914429 Utils: workaround for saving file opened by another application
...fixes file saving on Windows in specific circumstances.

File deletion on Windows is quite tricky. If you simply
remove the file opened by another app that shares it for
deletion the file might become semi-removed. It looks
like it still exists but it is in fact inaccessible for
any operations until the other app frees the handle.

To solve that case there is a ReplaceFile API call
which carefully deals with that case.

[Backstory] Oswald Buddenhagen insists that this fix is
rather a workaround and we should solve file access
problem in llvm.
For that purpose we have QTCREATORBUG-19404 and upstream
https://bugs.llvm.org/show_bug.cgi?id=35558

Task-number: QTCREATORBUG-15449
Change-Id: If37d484231b79d8e33822c795232dc31243c88c0
Reviewed-by: David Schulz <david.schulz@qt.io>
2017-12-15 13:55:41 +00:00
Ivan Donchevskii
010fb41700 Utils: take control over QTemporaryFile file lock
When we derive from QTemporaryFile we can't unlock file
to be used by outer functions.
With this change lock is managed by m_tempFile variable and
can be released by reseting m_tempFile.

Change-Id: I41339410471c69d1e73df49f04bc2d5c2036a064
Reviewed-by: David Schulz <david.schulz@qt.io>
2017-12-15 13:55:30 +00:00
Ivan Donchevskii
0dafe5cb8c Utils: improve savefile error messages
Change-Id: I505c33e1e56a67a3682de2e2cbfe2ab967d04242
Reviewed-by: David Schulz <david.schulz@qt.io>
2017-12-15 13:55:23 +00:00
Ivan Donchevskii
74a5083163 Utils: remove unused variable in SaveFile class
Backup member was never set to true.

Change-Id: I21dc889813820e2a463c5ba812b18b57766e03c4
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
2017-12-11 10:36:44 +00:00
Ivan Donchevskii
07c3a37054 Utils: improve failed file saving behavior
Remove temporary files left after fail.
Set error string for locked file.

Task-number: QTCREATORBUG-15449
Change-Id: Ibc8b01a4ea47870c29493a69718db929070ac13f
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
2017-07-03 09:29:51 +00:00
David Schulz
cc04b84917 Fix compiler warnings on windows.
Ignore some warnings inside 3rd party code and fix a lot of conversion
warnings.

Change-Id: I909f2f31a4639015bf7dd028d2d435ff1d1167bc
Reviewed-by: Christian Kandeler <christian.kandeler@theqtcompany.com>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
2016-04-22 07:37:31 +00:00
Tobias Hunger
f72370f20a Update License according to agreement with Free Qt Foundation
* Update remaining files in src

Change-Id: I1896f17fcf34f71c3310c87899fb5171b8e4afb1
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
2016-01-19 15:59:41 +00:00
Eike Ziller
3c85058694 Update License
Change-Id: I711d5fb475ef814a1dc9d2822740e827f3f67125
Reviewed-by: Alessandro Portale <alessandro.portale@digia.com>
2015-01-16 12:37:56 +01:00
Eike Ziller
8295b503be License update
Change-Id: I3c22ef2685d7aa589f5d0ab74d693653a4c32082
Reviewed-by: Alessandro Portale <alessandro.portale@digia.com>
2014-10-09 11:41:44 +02:00
Robert Loehning
746c5d8863 Incremented year in copyright info
Change-Id: Ib5423fdd064e4546f848c0b640b0ed0514c26d3a
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@digia.com>
Reviewed-by: Kai Koehne <kai.koehne@digia.com>
2014-01-08 08:29:47 +01:00
Christian Kandeler
1b6f89b417 Utils: Make sure we only use fdatasync() on systems that have it.
Change-Id: I7260c05081942acd5ecd7c66e864d4efc5041add
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
2013-02-06 18:03:31 +01:00
Oswald Buddenhagen
1fda2111d4 Merge remote-tracking branch 'origin/2.6'
Conflicts:
	src/plugins/autotoolsprojectmanager/AutotoolsProjectManager.pluginspec.in
	src/plugins/debugger/qtmessageloghandler.cpp
	src/plugins/debugger/qtmessagelogwindow.cpp
	src/plugins/madde/maemodeployconfigurationwidget.cpp
	src/plugins/qmldesigner/components/integration/designdocumentcontroller.cpp
	src/plugins/qmldesigner/designercore/include/widgetqueryview.h
	src/plugins/qmldesigner/designercore/metainfo/metainfoparser.cpp
	src/plugins/qmldesigner/designercore/model/modelnodecontextmenu.cpp
	src/plugins/qmldesigner/designercore/model/modelnodecontextmenu.h
	src/plugins/qmlprojectmanager/qmlprojectapplicationwizard.cpp
	src/plugins/qnx/bardescriptormagicmatcher.h
	src/plugins/qt4projectmanager/profilekeywords.cpp
	src/plugins/remotelinux/deployablefilesperprofile.cpp
	src/plugins/remotelinux/deployablefilesperprofile.h
	src/plugins/remotelinux/deploymentinfo.cpp
	src/plugins/remotelinux/deploymentsettingsassistant.cpp
	src/plugins/remotelinux/profilesupdatedialog.cpp
	tests/auto/icheckbuild/ichecklib.cpp
	tests/auto/icheckbuild/parsemanager.cpp
	tests/auto/icheckbuild/parsemanager.h

Change-Id: Ie465a578446a089e1c502d1cb1096e84ca058104
2013-01-31 16:25:33 +01:00
Robert Loehning
298531e370 Incremented year in copyright info
Change-Id: Ic6a9ff0359625021ebc061d22db6811814534205
Reviewed-by: Kai Koehne <kai.koehne@digia.com>
2013-01-29 16:27:03 +01:00
Knut Petter Svendsen
f556e8f5f2 Fix: Make sure umask is used when creating new files
When a new file was created from the file menu, the permissions
on *nix was always 0600 regardless of the proess' current umask.
Fixed by letting CorePlugin::initialize() initialize the umask in
Utils::SaveFile. Since getting the system's umask is not thread
safe this can't be done directly in SaveFile::open.

Task-number: QTCREATORBUG-6513
Change-Id: I10d8b2f4ab85574ed3004b5e646664c2255196b9
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2013-01-29 14:50:05 +01:00
Eike Ziller
6fd252b0a5 Merge remote-tracking branch 'origin/2.6'
Conflicts:
	share/qtcreator/qml/qmlpuppet/commands/endpuppetcommand.cpp
	share/qtcreator/qml/qmlpuppet/commands/endpuppetcommand.h
	src/plugins/debugger/qtmessageloghandler.cpp
	src/plugins/debugger/qtmessageloghandler.h
	src/plugins/debugger/qtmessagelogwindow.cpp
	src/plugins/madde/maemodeployconfigurationwidget.cpp
	src/plugins/madde/maemodeployconfigurationwidget.h
	src/plugins/remotelinux/deployablefilesperprofile.cpp
	src/plugins/remotelinux/deployablefilesperprofile.h
	src/plugins/remotelinux/deploymentinfo.cpp
	src/plugins/remotelinux/deploymentinfo.h
	src/plugins/remotelinux/deploymentsettingsassistant.cpp
	src/plugins/remotelinux/profilesupdatedialog.cpp
	src/plugins/remotelinux/remotelinuxdeploymentdatamodel.h
	tests/auto/icheckbuild/ichecklib.cpp
	tests/auto/icheckbuild/ichecklib_global.h
	tests/auto/icheckbuild/parsemanager.cpp
	tests/auto/icheckbuild/parsemanager.h
	tests/manual/ssh/tunnel/tunnel.h

Change-Id: I04d7761df6bd936ad00e0547974284c967d39580
2012-10-05 21:20:50 +02:00
hjk
386ca7c8dd Adjust license headers
Change-Id: Ice592c6de9951ee3b2c4cb52ed0bb3b6770e0825
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
2012-10-05 17:12:56 +02:00
Christian Kandeler
6e09fa8c70 Utils::FileUtils: Use Utils::FileName for file paths instead of QString.
Change-Id: I9ee4c0760820e9299e238c116936ce8ef140c727
Reviewed-by: Tobias Hunger <tobias.hunger@nokia.com>
Reviewed-by: Daniel Teske <daniel.teske@nokia.com>
Reviewed-by: Christian Kandeler <christian.kandeler@nokia.com>
2012-09-07 09:53:14 +02:00
Eike Ziller
1e71dccc9e Build fix for Mac OS
Change-Id: Iec4e4fdddf6b5eadbdcaae2500df841f0cf57dd4
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
2012-08-20 09:58:18 +02:00
Yuchen Deng
540c4b19f6 Fix compilation of MinGW-w64 4.7
Change-Id: Ieab538a077351549727c94dad17d4d77ab492a97
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
2012-08-17 17:48:04 +02:00
Oswald Buddenhagen
f1d0c37565 properly sync file's data on commit
this ensures that creator doesn't eat my config files on every crash.

Change-Id: I18f8135158e17d064774a49fe170b63c89517e49
Reviewed-by: Joerg Bornemann <joerg.bornemann@nokia.com>
2012-08-16 17:22:31 +02:00
Eike Ziller
e0e8cf3ada Contact -> qt-project.org
Change-Id: I7134d7de30bcf9f9dcfad42520dd45ee083a852d
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
2012-07-19 13:23:21 +02:00
hjk
2931a499e6 Long live the king!
Change-Id: I2b72b34c0cfeafc8bdbaf49b83ff723544f2b6e2
Reviewed-by: Daniel Teske <daniel.teske@nokia.com>
2012-01-26 19:55:36 +01:00
Eike Ziller
6e6c9f9884 Don't try finalizing files that were never created.
Task-number: QTCREATORBUG-6643

Change-Id: I04945ebb39caace476a12f293666cfcec0f8a9e5
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
2011-12-05 22:11:52 +01:00
hjk
31600758de all: s/info@qt.nokia.com/qt-info@nokia.com/
Change-Id: If18afb5d4665924e7d9250dccbc60a65e6daa75e
Reviewed-by: Eike Ziller <eike.ziller@nokia.com>
2011-11-03 10:33:19 +01:00
Vlad Brovko
7d22c10143 don't rewrite symlink on save, rewrite target instead
Merge-request: 399
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>

Change-Id: If81446a8fd49e9de7611c2f09abd39af2c9c930d
2011-10-20 22:33:54 +02:00
Friedemann Kleint
2f92eae7bc Utils/Coreplugin: Clean headers.
Change-Id: I1e0d432127651622d40ff990e1866eac9fac46a0
Reviewed-on: http://codereview.qt.nokia.com/3091
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
2011-08-17 12:58:38 +02:00
Tobias Hunger
aa2acec14c Fix/add copyright headers
Change-Id: I8b73d583be1ee7183f4074bce49d5390e38631a2
2011-05-06 15:17:05 +02:00
Oswald Buddenhagen
1757217da6 add Utils::SaveFile: class for atomic saving of files
inspired by KSaveFile
2011-04-18 14:10:12 +02:00