void HistoryImportThread::run() { // we have to use this guard as a parent for HistoryImporterChatData // without this there is a backtrace: // "Warning: QObject: Cannot create children for a parent that is in a different thread." // and Kadu is crashing as in http://kadu.net/mantis/view.php?id=1938 QObject *guard = new QObject(); History::instance()->setSyncEnabled(false); ImportedEntries = 0; foreach (const UinsList &uinsList, UinsLists) { if (Canceled) break; ImportedChats++; Chat chat = chatFromUinsList(uinsList); // we cannot import into non-existing chat // this means chat with ourself on the list if (!chat || !chat.data()) continue; QList<HistoryEntry> entries = HistoryMigrationHelper::historyEntries(Path, uinsList); // guard as a parent. See above HistoryImporterChatData *historyImporterChatData = chat.data()->moduleStorableData<HistoryImporterChatData>("history-importer", guard, true); if (historyImporterChatData->imported()) { ImportedEntries += entries.count(); continue; } ImportedMessages = 0; TotalMessages = entries.count(); if (Canceled) break; foreach (const HistoryEntry &entry, entries) { if (Canceled && CancelForced) break; importEntry(chat, entry); ImportedMessages++; } if (Canceled && CancelForced) break; historyImporterChatData->setImported(true); historyImporterChatData->store(); // force sync for every chat History::instance()->forceSync(); } // delete guard, so HistoryImporterChatData is properly destroyed delete guard; History::instance()->setSyncEnabled(true); }