Qt translation - Crashes in Mac
-
Hello,
I have an application developed with Qt 5.2.1 and it works perfectly on Windows system . I'm trying to make it work on MacOS with XCode but* i got a crash when i'm installing a new translator into the qApp* for the translation (when the user selects another language).
Debugging with XCode (which i have no idea), throws me an* EXC_BAD_ACCESS *just after installing the new translator and redirects me to the app.exec() to the main file.
At the moment of installing the new translation , there is a previous one installed from the main when the program starts. The sequence is this:
- Main-> set the default language ->Open MainWindow
- MainWindow->User Changes the language (and i'm trying to access the qApp pointer from here to install the translator).
Can someone help me with this? Thanks in advance :)
PD: If i comment the line of the installtranslator method, the application works well but no translation is made hehe. Also the translator loads well the language before trying to install it.
EDIT: Crash report
@Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 QtWidgets 0x0000000114036c57 QLabel::setText(QString const&) + 23
1 QtWidgets 0x00000001140e0d12 QColorDialogPrivate::retranslateStrings() + 82
2 QtWidgets 0x00000001140e16ce QColorDialog::changeEvent(QEvent*) + 30
3 QtWidgets 0x0000000113f5592f QWidget::event(QEvent*) + 2799
4 QtWidgets 0x0000000113f1cf2c QApplicationPrivate::notify_helper(QObject*, QEvent*) + 300
5 QtWidgets 0x0000000113f1fa1d QApplication::notify(QObject*, QEvent*) + 6157
6 QtCore 0x000000010b9690b2 QCoreApplication::notifyInternal(QObject*, QEvent*) + 114
7 QtWidgets 0x0000000113f55b7d QWidget::event(QEvent*) + 3389
8 QtWidgets 0x0000000113f1cf2c QApplicationPrivate::notify_helper(QObject*, QEvent*) + 300
9 QtWidgets 0x0000000113f1fa1d QApplication::notify(QObject*, QEvent*) + 6157
10 QtCore 0x000000010b9690b2 QCoreApplication::notifyInternal(QObject*, QEvent*) + 114
11 QtWidgets 0x0000000113f55b7d QWidget::event(QEvent*) + 3389
12 QtWidgets 0x0000000114049807 QMainWindow::event(QEvent*) + 935
13 QtWidgets 0x0000000113f1cf2c QApplicationPrivate::notify_helper(QObject*, QEvent*) + 300
14 QtWidgets 0x0000000113f1fa1d QApplication::notify(QObject*, QEvent*) + 6157
15 QtCore 0x000000010b969c07 QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) + @ -
Hi,
What I use it this:
@
qApp->removeTranslator(&translator);
QString strFullFileName(QString("%1/HD120_%2.qm").arg(m_langPath).arg(strLang));
if (translator.load(strFullFileName) == true)
{
qApp->installTranslator(&translator);
}
@
So maybe the removeTranslator and load function protect me from setting up a incorrect translator. It never crashes in my program. -
Hi Jeroentje,
Thanks for your answer.
I'm checking like you the translation process (first removing the translator from the qApp pointer, and after it loading the new .qm file ,it loads the file well).
In fact sometimes (not always) the change event of the language is thrown and i get it (just sometimes). Also the application is translated when i execute it again (I store it in QSettings).