So, one more attempt. Previous articles (part1, part2) mentioned possible solutions to fix crash insinde the QTreeWidget and QAccessibleTableCell.
Unfortunately, deselecting current item still doesn't fix all issues. The problem with deselection is that it's not handled correctly via QAccessibleTableCell:
If current index isn't valid, QAccessible doesn't correctly update currect QAccessibleTableCell object which caused all this evil crashes.
So there are two ways how to fix it. One is to manually set QAccessibleTableCell but I didn't find a way how to do that. The second way is to disable QAccessible for Property editor. Unfortunately it's not an easy task. In QAccessible exists method setActive:
But this method works only with AccessibleObserver class but not with QPlatformAcessibility which handles real QAcessible::isActive result. Because of this it's necessary to update setActive method in file qacessible.cpp inside the Qt.
and updated version:
In case you will find better way how to turn off accessibility, please let me know.
But there is still one more problem. Occasionally OS X decides to switch accessible back on:
And this is probably the reason why everything works ok on older OS X but not on 10.10. Because OS X 10.10 randomly turns accessible on which causes this crash. Accessible is usually turned on when opening some modal dialog.
This explains why opening an empty dialog increased the probability to crash the application. The only solution I have found is to disable QAccessible every time the PropertyEditor is cleared up.
This crash took me about 40hr+ to replicate and find a way how to eliminate it (unfortunately not to fix it). This crash occurred only on OS X 10.10, not 10.9, not Linux, not Windows.
Bug occurred in slightly modified QtTreePropertyBrowser where we have additional buttons for each property.
When any of these buttons caused property tree refresh, application randomly crashed. But when these actions were executed by buttons outside of the property tree, everything worked fine.
I updated methods from signals-slots mechanism to QEvent system. Unfortunately this didn't help as well. Next attempt was QTimer usage instead of QEvent or signal-slot to simulate real click. But also without any success.
With a lot of luck I finally found the reason for the crash. It's caused by erasing a property tree (and inner QTreeWidget) together with an active focus on this widget. Unfortunately I'm not able to fix it in the QtCore because according to callstack there is only some QModelIndex manipulation without any sight of what's going wrong.
The effective solution how to fix this wrong behaviour is to temporally set focus to another widget (or parent), clear the tree and set focus back to property tree. Unfortunately this solution doesn't work. Check part II of this article for better solution
If anyone know how to fix that, I will be glad for any info.
To be more specific, problem occurs only in very specific circumstances. It's in situation, when application is compiled as console-app and it's compiled on Mac OS X version older than 10.9:
and when you're using QEventLoop::exec in mode processing all events except user events (QEventLoop::ExcludeUserInputEvents):
In this situation, application hangs-up. When the application is compiled with GUI mode or when application is compiled on Linux/Windows (no matter if gui or console), everything works find. To fix this problem, it's necessary to implement hack similar to this (simplified version):
This is very interesting crash and I think it should be considered as Qt bug. This problem arise only under very special circumstances. But one after another.
You will identify this problem when your application stopped/exited immediately after the start without any visible error message. It looks like the application isn't executed at all. When you check application log (Computer -> manage -> Event viewer -> Windows logs -> Application), you will see Error logs:
The most interesting part of this log is crash location: ntdll.dll
At first sight it seems like some problem inside the windows. But the opposite is true, the problem (as almost always) is inside your app ;-).
As the next step, you can try to debug this executable via Visual Studio to see what happens inside. Simply open executable as project together with .pdb files and execute it. Now you can see that application is correctly executed but crashes as soon as it touches Qt library. The location of crash is inside ntdll.dll in RtlHeapFree() function.
So the problem is inside the Qt, right? Almost true, but not for the 100%. When I tried to run this application on computers of my colleagues, everything works ok. So why the application doesn't work on my computer too?
The problem is in new Qt5 plugin system. Besides the common Qt5*.dll files which are loaded immediately after the application start, Qt5 is also loading plugins/platform-plugins dynamically when the application is executed. To locate this plugins, Qt5 uses following method to identify directories where to search for plugins:
For some strange reason this library returns as first directory path where Qt5 libraries were compiled and after that location based on the executable. So if your Qt5 path is C:\Qt5, this will be the first path where all plugins are searched for, no matter if the correct version of plugin is located in APP\plugins or APP\platforms. **I think this is serious bug in Qt5**.
Where is the problem?
And here we're getting to the core of the whole problem.
**If application is compiled on computer with one compiler and used on second computer which contains the same path to which original computer has installed Qt, the application will load all plugins from your folder instead of itself folder.**
In case your computer will contain different version of Qt, different compiler or different platform, application loads incorrect libraries and crashes. Completely, silently and without easy way to determine what's wrong.
The solution is simple, but it isn't achievable from outside of the Qt library. It would be necessary to Qt as first tried to load libraries from application directory. And only if no plugins were found in application directory, the application would try to search for plugins in Qt directory.
Qt change solution
The simplest way how to fix this issue inside the Qt library would be to rename/update appendApplicationPathToLibraryPaths function to prependApplicationPathToLibraryPaths and change
Unfortunately it isn't possible to simply change this behavior from your app. All of these operations happen directly in QCoreApplication constructor so if you try to change it after, it's too late.
The temporary solution before this problem will be resolved is to reinitialize library paths before QCoreApplication is initialized. It's necessary to clean libray paths, compute new paths and re-initialize QCoreApplication::libraryPaths before QCoreApplication object is initialized. This can be done in main.cpp of your application before you will create QApplication/QCoreApplication object.
It's not a nice solution, but it works. I tried to report this issue also to bugreports.QtProject, so maybe in later version this will be fixed.
One of very useful feature of Visual Studio is custom variables views. It's possible to configure own views to each of your class. For this, VS2013 (and VS2012) uses .natvis files located in following directories:
Files are stored in common .xml format and has following format:
Debugging .natvis files
Visual studio contains a way how to catch syntax and logical errors in natvis format. All warnings/errors can be displayed to Visual Studio output panel by specifying following registry key to "1".
Note: It's necessary to restart Visual studio to turn on this feature
We encounter several problems when we tried to deploy our new version of ORM Designer - Skipper to our new web site skipper18.com. Although new Skipper installer is very simmilar to ORM Designer installer, when downloading this exe-file from the new site we are getting this error:
The problem is somewhere in chrome/IE when evaluating downloaded file. Probably combination of new site, new executable and new name of product is the problem.
To fix this issue, we decided to sign-in installer and application executable by **Code-signing certificate.** There are a lot of certificate providers and the costs are very different. A lot of providers are selling these certificate for around $500/year. Fortunately it's possible to found certificates also for $75 - $95/year. The cheapest one is from tucows.com but based on the site and additional tools I decided for ksoftware.net, The price $95/year isn't so different but they offer also command line and GUI signing tool for their certificates called kSign.
Fill your company details, pay with paypal and wait until someone from Comodo will contact you with additional details. It's necessary to have the same contact information on the domain registration as on certificate registration. It is also necessary to have company registered in one of publicly available lists with the same company information as on certificate registration.
Next step is a validation through phone call. It is a quick call when you confirm registration info through the call in order to verify your phone number. Phone call is the last necessary step and then you receive email with certificate:
Signing of the application and installer is pretty easy. K-Software offers two applications for this purposes. The first one is with GUI, second one is command line based. Both applications need only few parameters like where the certificate is stored, certificate password, application description, link and executable location:
Command line application is executed through following command:
And that's all. Now if you checked your executable through properties in Windows explorer, you see that your application is correctly signed:
Our reporting tool occasional crashed on MacOs when was executed with several command line params. Command looked like this:
When inspecting exception report, we found following stack trace:
After some google-searching I found out that the problem is in core of our application. When subclassing Qt QApplication, it's necessary to pass argc with reference, not by value. So after adding one little &, everything works like charm!
My VS2010 on every build always recreate all .moc files and associated .cpp files. Problem was in incredibuild clausule during compilation of my Qt libraries.
Although qmake added all these incredibuild defines to my VS project, Incredibuild still doesn't compile it in parallel so it was totally useless. The most simply way is edit incredibuild_xge.prf and turn-off it.
The problem is that starting with OSX 10.9 Apple changed default standard c++ library from libstdc++ to libc++.
Qt binary distribution compile with -stdlib=libstdc++ to be compatible with 10.6, Xcode 5 on 10.9 will select -stdlib=libc++ by default (for OS X 10.7 and better only). So symbol using classes from the standard library (like std::string in this case) will not resolve correctly at link time.
So it's necessary to compile all libraries with one type of libstdc++ (or libc++). Because I need to keep 10.6 compatibility, it's necessary to compile boost and other libraries with libstdc++ dependency.
To check which library is used, use otool tool:
As result you will get something like this (check /libc++1.dylib):
How to fix it for boost
it's necessary to recompile boost (and don't forget to remove ./bin.v2 directory) with these params:
and run otool again:
How to fix it for CMake libraries
In case you're using library which is built by CMake system, you need to add following flag:
How to fix other libraries
For any other library it's necessary to pass libstdc++ flag in any available way, for example modify makefile and add :
Second way how to fix it, compile app using latest compiler
Another way is to update mkspecs to compile for latest MacOS version, after that, compiler will be the same like compiler used on all other libraries. To do that, it's necessary to update file:
It's necessary to configure which parameters are passed to fast-cgi application from nginx server. For this purposes serves fastcgi_param keyword. It's a good practice to keeps all fastcgi params together. For this purposes nginx has fastcgi.conf file. This file already contains most of useful fastcgi_param bindings.
To include this file use include statement:
How to pass custom headers to fast-cgi app
Default configuration pass only default headers to fast-cgi. It's necessary to add few more configurations statements:
After that headers are passed as HTTP_* parameters:
FastCGI comes with Win32 project for VisualStudio6. Unfortunately when you try to open it in VisualStudio2010 the project will be corrupted. To correctly compile it for VS2010 it's necessary to download library sources, get patches from cybozu.co.jp site and apply it.
Today my Visual Studio 2010 started to execute my application super slowly. When I tried to execute my application (without any changes in source-code) the delay between "Start Debugging" and application start was about one minute.
I know that too many breakpoints or breakpoints in templates could caused this, but I don't see any breakpoint in my Breakpoints window.
But as I have found that the problem was really caused by breakpoints. In some special cases - when you're using some external tools to modified your project file (.sln/.vcxproj) - breakpoints can disappear and begin to make a trouble (I'm using Qt qmake to update my project based on .pro files.)
The solution is pretty easy. Use **Delete All Breakpoins** from Debug menu:
For our side-project used for customer analytic we need simple way how to generate HTML pages with tables and charts. As HTML5 UI framework we're using Foundation and for tables jQuery Tablesorter. Now the question is which chart library use for charts.
[caption id="" align="aligncenter" width="637"] The procedure entry point GetTickCount64 could not be located in the dynamic link library KERNEL32.dll[/caption]
Today we received report from one of our customers about problem with our ORM Designer on WindowsXP - 32bit. Our latest version returns following error:
The procedure entry point GetTickCount64 could not be located in the dynamic link library KERNEL32.dll
**The problem is that GetTickCount64 doesn't exists in XP system**.
It's necessary to compile your application (and any library which uses GetTickCount64) with correct **WINVER** and **_WIN32_WINNT **defines value. List of WINVER values for all Windows version can be found here.
You can define these values in your resource.h file:
#define WINVER 0x0501
#define _WIN32_WINNT 0x0501
or add it to a project property -> C/C++ -> Preprocessor -> Preprocessor Definitions:
If you want to define these values automatically in Qt project, add following lines to your .pro file:
#Windows XP compatability
DEFINES += "WINVER=0x0501"
DEFINES += "_WIN32_WINNT=0x0501"
Even though I find phpMyAdmin and similar tools useful I don't like them on production servers. When I spent a lot of my time protecting website against SQL injection I don't want to leave opened doors to access the database through phpMyAdmin. Many phpMyAdmin installations are not protected with HTTPS and just one login on a public or attacked wifi can lead to a lot of troubles. So I recommend to delete the phpMyAdmin installation from the server and start with a more comfortable and secured way to do the task.
SSH tunnel will give you the security you're looking for. Start your Putty, load the session and configure tunnel:
I've selected port 3366 to be used on my local machine so it avoids conflict with my other installation. Now I can connect from any tool to MySQL database at localhost:3366. I prefer Netbeans IDE and MySQL Workbench which is also really great for server/user configuration.
We are using SSH a lot to deploy our projects and to do common maintenance tasks. If you are accessing your server many times a day you might find frustrating typing the password all the time. You can use private key instead. Here are some detailed articles about adding RSA key and configuring SSH daemon. Bellow is a summary of the basic steps for Windows users.
Putty which is a great alternative to the Linux tools. To generate private/public key you should use PuttyGen.exe. Run the application, click generate and follow the instructions. It's a good idea to put your name into the key comment so you could easily recognize your public key in configuration files. You should also protect your key with a password.
Copy the public key which is located in the big text field above Key fingerprint field. Append the public key into /root/.ssh/authorized_keys file (if you want to login as root). You might need to create this file if it doesn't exist already. Click on Save private key button and save the key to a secured place. You can now use this private key to login with putty to the remote server. To make things more comfortable you can use an agent to store unlocked private keys in the memory while you are logged into your computer. Run this command after you login:
Without any further settings you should now be able to login to the remote SSH without password. If everything worked as expected you can now disable password authenticated access to make your server more secure:
To load you key after you login to a Linux box (useful for deployment) insert:
# include .bashrc if it exists
if [ -f ~/.bashrc ]; then
keychain --clear id_rsa
Now we have a little bit more secured but more comfortable way to use SSH.
During our development we found that Microsoft RegEx (Regular expression) implementation contains a bug which caused crashes of our applications. The application module using RegEx passed all unit test, but sometimes under heavy usage the application crashed at our customer. Because we use **BugTrap **for error and crash notifications, we knew the error was in atlrx.h file.
After several hours of testing and searching we found the bug. The crash didn't occur after first code execution, but we had to run thousand iterations of the same code over and over. The bug is located in file atlrx.h at line 708.
Original file looks like this:
sz = CharTraits::Next(szCurrInput);
szCurrInput = sz;
if ( sz == NULL || *sz == '')
ip = 0;
pContext->m_nTos = 0;
Problem is, that variable szCurrInput have in some circumstances NULL value and this causes the crashes.
We change the first two lines. It is necessary to test szCurrInput variable for NULL and empty string value. If szCurrInput is NULL or empty string, it's necessary to stop processing RegEx. Otherwise stack overflow during processing string occurs.
Some time later we had other problems with Microsoft RegEx implementation and non-standard RegEx syntax. So we left MS RegEx parser and moved to Boost.Regex which is really nice piece of code (as well as other libraries of the Boost pack) and supports Perl and POSIX regular expressions. Whole Boost library is carefully unit test and can be relied on.
Today I encounter this error after applying **macdeployqt** to my application. There is a lot of questions about this topic on google but not very answers.
The most important thing is setup following variable.
Using this you will se which libraries are loaded during execution of your application. The interesting thing is, that I see loading a libraries from their original directories instead of Application.app. But when I temporary moved these libraries from their location, libraries begin to load from then bundle location.
The reason for my "QWidget: Must construct a QApplication before a QPaintDevice" was executing an older version of QTitanRibbon from shared libraries path instead of the newest one compiled directly to /usr/lib.
The second reason for this issue was caused by another path in "export DYLD_LIBRARY_PATH". It seems that application search for libraries first in DYLD_LIBRARY_PATH and after in paths from their inner records.
This short post will show you how to resolve following error during Qt compilation on 64-bit windows:
This error is caused by bug in **QMAKE_HOST** variable used in WebCore.pro file. This variable is tested to determine destination platform (x86 or x64).
This variable contains x86 value also on 64-bit builds instead of x86_64 value. This value is tested on the following line in a WebCore.pro file:
If you want to fix this error, simply replace **QMAKE_HOST** by **QMAKE_TARGET** variable. Updated line should look like this:
After this update all required asm defines are correctly included and build of WebKit will be successful.
Update for this error
In newer versions of Qt there is already applied fix the error with QMAKE_HOST / QMAKE_TARGET, but also there is a new problem ;-(.
The Problem is in the following "if" definition:
When you compile your project for MSVC 2010, .asm file isn't included. It's necessary to add win32-msvc2010 to this definition. So updated WebCore.pro for Qt 4.8 will look like this:
Next problem solution
Next problem which I found during compilation is wrongly set QMAKE_TARGET.arg. For unspecified reason, when I compile 64bit library in 64bit system in 64bit VS command line, this variable has value x86 instead of x86_64.
The problem is in the qmake project.cpp file. QMAKE trying to determine 64/32 bit version based on the %PATH% configuration. Qmake search for VS-PATH\bin\amd64 of \bin\x86_amd64 string. Unfortunately there is a bug in concating searched string. This is how looks original project.cpp file at line 3177:
The problem is, that VCINSTALLDIR contains \ at the end of the string, and then we append \ again. So, result is:
Now, QMake correctly determine 32/64 bit compilation and then correctly include PaintHooks.asm and your Qt WebCore will be sucesfully compiled.
If your application using some externals dynamic libraries (called .dylib in MacOs system), you have to provide all these libraries. The simplest way is to provide these libraries into the Application.app directory.
Find out which libraries are used
Qt provide really useful tool called **"otool"** which serves to lots of purpose. One of them is to detect which shared libraries are required by our application. For this purpose otool has parameter -L. The usage is following:
Output could looks like this:
Output from "otool" is simmilar to linux tool "ldd".
The Mac Deployment Tool
Because manual copying and configuring all shared libraries to our application could be difficult, Qt have deployment tool which do all work for us. Tool is called "macdeployqt" and can be found in /Developer/Tools/Qt/macdeployqt.
**Note:** Every time when you call macdeployqt tool, project have to be build from scratch. But is sufficient when whole result directory is removed and linked again:
Quick post about problem which I already solved, but think that could be handy for someone else.
I have following code:
When compiling under Visual studio, everything is ok. But when try the same code snippet under g++, have following error:
This is because compiler doesn’t known FindByType method, because T2 is templated argument. The solution which I found is in adding keyword template before FindByType method name. So updated source code will look like this:
After this update, code will be compiled correctly under both compilers.
Sometimes happened that two DLL libraries wants to be loaded in same address. These DLL libraries can be found in "Modules" window with small red exclamation mark. When you need to change this address, you have to update your linker settings adding the /BASE: parameter.
Compilation under Windows is possible only using MinGW and with few modifications in TENG code (because there is few glitch which didn't meet c++ standards). If you want more information or updated TENG version, please let me know.
Today I found out that Windows version of Git doesn't support Unicode character in file names. After some time spent by searching on google, I found updated version of msysgit with Unicode support. This version is available here: http://tmurakam.org/git/. Thank you Takuya Murakami!
Here is a simple example how to use the iconv library.
During my attempts with libiconv library I encountered two different problems:
Converting function returns 0, but pOut is empty
This is because iconv function modify pOut ptr during string processing. When you need to access output buffer after **iconv()** function finish its work, you have to access it via different pointer than one passed to this function. In my code I'm using *dst and pOut ptrs;
Conversion between different character sets returns strange results
Check if have correct order of parameters in your **iconv_open()** and **iconv()** function. Function **iconv_open()** has as its first parameter OUTPUT encoding, and as second parameter INPUT encoding. While **iconv()** function has as first parameters INPUT variables, and as second parameters OUTPUT variables. This inconsistency is really confusing.
Lots of open source libraries (like libiconv, libintl, ...) doesn't have MSVC project files or makefiles. Only supported way how to compile given library under Window is using MinGW and MSYS compiler tools.
Here is step-by-step guide how to download, install and compile libraries using MinGW.
Run downloaded executable. As install directory leave C:\MinGW. It's recommended not to change this path. On component screen select C compiler, C++compiler, MSYS Basic System and MinGW Developer Toolkit.
After that select next,next,next, finish ;-). After that installer downloads all necessary files. This could take a few minutes.
When installation is done, as next step is necessary to setup PATH variable to c:\MinGW. Installer doesn't modify it automatically. (more info about modifying PATH variable) .
Installing additional gcc compiler and make support
These two packages isn't listed in available components. If you wish to install it, use mingw-get-inst. In c:\MinGW\bin directory run following commands:
Step three compiling
Compiling from windows shell
Launch cmd tool, go to directory with source code and use g++.
Compiling from MinGW console
Launching MinGW console
Laung MinGW from startmenu or msys.bat from %INSTALL_PATH%\MinGW\msys\1.0\msys.bat.
Command line for generating Visual studio project file from Qt .pro file.
Missing moc_*.cpp file
When some of moc file isn't properly generated and getting following error:
Select corresponding .h file (for moc_xxx.cpp select xxx.h) in a project tree and select **Compile** from context menu. If the file is marked as "up-to-date", try to change something in this file and repeat a compilation. If in the output window will be "up-to-date" again, you found a problem.
Use context menu on the corresponding .h file, select properties and edit "Configuration properties |Custom build steps|General|Outputs" to any value (add some char to the end of value), confirm change by Ok button and then return value back to original (remove added char). After that, compilation on correspond file will be successfully performed.
Today I continued with UI skinning and enhancing visual feel from application. After few hours spent by searching a way how assign two different keyboard layouts to one screen (numerical for cash amount and alpha-numerical for comments), I gave it up and wrote to the Airplay forum. I hope that this function will not be a big problem and will be solved.
So result of my today work is full reworked icon list with automatic layout related to screen resolution and with full skin support. Here is result:
I realy like it and on iPhone with finger ability is icons-list much more better ;-)
Because Airplay SDK doesn’t have direct GUI support for iPhone applications, you have to skin all controls on your own. After a little search I found complete UI Photoshop .psd file where are all necessary controls in separate layers.
Today I spent several hours by reading a documentation and trying lot of examples. Create UI to be like iOS as much as possible in Airplay will not be easy ;-). There is lot of obstacles that I will have to overcome to accomplish a desired GUI. Here is a result from my first day of work:
Airplay SDK is great framework for developing multi-platform applications (but primary games), but create nice iOS GUI is a real challenge ;-).
Today I finished application logic coding and it seems that all works ok ;) (or at least my unit test says that). Currently application can compute and simplify complicated loans relation and returns a result with minimal payback operations. Because a picture is better than thousand words, there are few examples:
On beginning, a simple example when Alice lends $10 John, and John lends $10 Bob. Instead of complicated payback from one person to another, there is a simply equal solution, where Bob will payback $10 directly to Alice:
Now little bit complicated example:
As you can see, after this optimization you save three steps.
And finally even more complex example:
Alice lends $100 John, John lends $50 Bob, Bob lends $20 Alice and Jane lends $10 Bob. Do you know how to payback money simply without duplicate the transfers? ;-).
And this is all for now. Application can handle also multiple loans to more people. I will try to prepare another examples of what application can do ;-).
After windows implementation and action manager which makes my life a lot of easier, today I continue in extending of my UI framework builded upon Airplay SDK. I’m currently developing screens which have lot of input widgets and getting/setting data to this widget becomes a nightmare ;-). So, I implement simple DDX functions known from C++ MFC framework. This helps me to have a code much more cleaner and to maintain screens easier. And here are few screenshots from my today work:
A next goal during my work on the Party money application was a date selector. Because Airplay doesn’t have a native support for Apple Date widget, the whole element is created by using several CIwUIScrollableView controls. After few hours of trying to figured out how all things work I have finally working date selector ;-). Here is a screenshot from date selector with default (ugly ;-)) skin.
Because list of icons looks really good for me, I decided to use it everywhere where it is possible ;-). I extend list classes, so buttons can have different sizes and customized captions. Besides icons choosing this widget will be used for displaying a person in a profile and for choosing person in a transactions.
A next screen widget which I need for my Party cash application is scrollable grid of icons. What looks simply became a problem which needs several hours ;-). Again, because Airplay SDK doesn’t have any prepared widget, I have to create a new by using several existing ones. Result looks very promising, but currently without a final skin. So buttons have ugly default gray skin ;-).
Altough I still explore lot of features and possibilities of Airplay framework, definitely I know that framework has only limited support for complex UI applications. Guys from Airplay SDK do a lot of work for 2D and 3D applications, and have a basic support for creating and skinning app windows and widgets. But what I really miss is some layer which helps you with window creating, event handling and so on.
So, I decided to create one on my own which is based on my another project Atomix - a large project for Visual C++. Currently I have implemented a window manager and action manager for Airplay SDK. So now, instead of writing lot of code for creating and handling windows, I have everything encapsulated in few objects and all my screen objects are derived from these base clases.
Still a lot of work has to be done to achieve the final application ;-)
As the first thing in Part-cash application development we brainstormed an application diagram. I think that during time some screens will be extended or modified, but major part of the app will be the same. And here is a screenshot of our whiteboard after three hours of drawing and erasing ;-)