[SOLVED] Application crashes on clipboard copy or cut (but not paste)
-
An application I am developing crashes when either cut or copy is used, yet somehow paste is not affected.
UPDATE It occurs when using QInputDialog::getText(...), but not for QInputDialog::getMultiLineText(...).
It does not crash on my development machine (windows 7, Qt 5), however it does on my other PC (windows 7, Qt 5). Unfortunately the crash information is very limited, right after cut or copy is issued, a window pops up saying 'A problem caused the program to stop working correctly. Please close the program.'.
Oddly enough it does not happen with other apps I've developed, even though they use the same call to QInputDialog::getText(...).Any ideas on what could cause the crashing?
-
I wasn't using QInputDialog::getText(...) to copy, its the QInputDialog convenience function to get a single line of text (ie. it pops-up a dialog box with a QLineEdit).
-
Found the solution... the problem was an error in my QThread.
It uses QAxObject to communicate with Excel.Anyway, on starting the thread 'run()' I called 'CoInitialize(NULL)', and then for simplicity I had a call to 'CoUninitialize()' in the thread destructor.
Once I moved the 'CoUnitialize()' call to the 'run()' function (at every exit point), everything works fine.Strange how it only seemed to mess with the clipboard.