Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Qt Solutions archive, is it safe to use them for new projects, are there replacement Classes?
First of all, I'm quite new to Qt. About 1 month of learning the framework, so sorry if the questions are too vague.
I'm planning to use Qt as the framework to support the migration of a legacy system, that is non-unicode and WIN32 API calls exclusively.
So the benefits are many I know, so right now I'm trying to find replacement for the very basic functionality the WIN32 API offered (non-gui) like, files, threads, networking, serial communication, etc.
The first thing I haven't found a direct replacement is for File Locking, which is essential as the legacy system has a tiny Database engine, and we use the Locking mechanisms of "LockFile" win32API Call where we could even lock certain bytes of a file to enforce different isolation levels.
Searching the web, I found references to the Qt Class "QtLockedFile". But now it is not included in the SDK. So I thought it had been deprecated and something new created, but apparently not. I found it as an add-on called "Qt Solutions archive" ( http://qt.nokia.com/products/qt-addons/solutions-archive/index )
But then on a blog explaining changes to future Qt versions ( http://labs.qt.nokia.com/2011/05/12/qt-modules-maturity-level-the-list/ ), it is said all this classes are deprecated.
Can someone tell me if there's a replacement to QtLockedFile and QtService? What would be the best thing to use?, (I need exactly the functionality these classes have). Why were they removed from the SDK?
Thank you all in advanced for your comments and suggestions
Chuck Gao last edited by
Seems no replacement can use right now. I think you can still use the deprecated solutions/classes. They're deprecated, but the deprecated just mean not maintenance any more ? If so, i think it's safe to use
giesbert last edited by
They work, definitly, but are not enhanced anymore. You just have to check your license (I'm not sure which license agreement they have :-) ).
AFAIK, QtLockedFile just locks the whole file, not parts of it.
Ok, thanks for the info. It’s strange that if they work correctly they have become deprecated just because they are not enhanced anymore. Actually that is an excellent thing about the WIN32 API, it’s extremely rare anything becomes deprecated. They just make newer API calls ("LockFileEx"), that way they don't break any code (The legacy system I'm trying to port works from Win95 SE, to Win 7, or server editions without changing 1 line of code when a newer windows ver arrives)
Anyway, the locking of files it’s actually quite important for us, and I think Qt doesn’t support it natively because Linux doesn't provide a reliable API Call for this!!!! (Didn’t know that until know, very new to Linux as well http://0pointer.de/blog/projects/locking.html). It is a very low level requirement. Kind of a "mutex" requirement but for files. Cannot imagine a big system without mutex or locking for that matter.
So I guess the easiest option is to use the QtLockedFile and if problem arises, compare it to other open source projects that require File locking such as SQLite: http://www.sqlite.org/lockingv3.html
Does anybody have a better alternative for file locking in multiplatform?
(IMHO Qt should provide a default file Locking API, and mention its limitation on different platforms, otherwise a lot of people like me have to implement their own broken functionality over and over)
I’m starting to work on a new implementation for Qt-5.1, based on my work on KLockFile in the past.
The problem with the QtLockedFile implementation, according to my earlier research, is that fcntl(F_SETLK) locks other processes, but not other threads (we might as well handle both…) and it unlocks when just reading the file in the same process (!). http://apenwarr.ca/log/?m=201012#13
So instead I’m setting out to write a QLockFile class, which does NOT inherit from QFile, but creates a separate lock file.
Well David, that sounds like an interesting project, and probably a lot of people would benefit from it. Let us know your progress, and if we can be of any help :)
sahumada last edited by
Qt Solutions is on Gerrit and some people are contributing to it .. see the activity here https://qt.gitorious.org/qt-solutions/qt-solutions
You can help by reviewing https://codereview.qt-project.org/46583
(and even by contributing a Windows implementation :-)
I could use some help with Windows APIs ... Is there a way to check if a process is still running, based on a process ID?
I found GetCurrentProcessId(), now if I write this into a file and read it in another process, how can I find out if a process with that ID is still running?
(the equivalent of kill(pid, 0) on unix)