1 /**
2 * UGENE - Integrated Bioinformatics Tools.
3 * Copyright (C) 2008-2021 UniPro <ugene@unipro.ru>
4 * http://ugene.net
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19 * MA 02110-1301, USA.
20 */
21
22 #include <qglobal.h>
23
24 #ifdef Q_OS_WIN
25 # include <tchar.h>
26 # include <windows.h>
27 #endif // Q_OS_WIN
28
29 #ifdef Q_OS_DARWIN
30 # include "app_settings/ResetSettingsMac.h"
31 #endif
32
33 #include <QApplication>
34 #include <QDesktopWidget>
35 #include <QIcon>
36 #include <QMessageBox>
37 #include <QStyleFactory>
38 #include <QTranslator>
39
40 #include <U2Algorithm/AlignmentAlgorithmsRegistry.h>
41 #include <U2Algorithm/AssemblyConsensusAlgorithmRegistry.h>
42 #include <U2Algorithm/CDSearchTaskFactoryRegistry.h>
43 #include <U2Algorithm/CudaGpuRegistry.h>
44 #include <U2Algorithm/DnaAssemblyAlgRegistry.h>
45 #include <U2Algorithm/GenomeAssemblyRegistry.h>
46 #include <U2Algorithm/MSAConsensusAlgorithmRegistry.h>
47 #include <U2Algorithm/MSADistanceAlgorithmRegistry.h>
48 #include <U2Algorithm/MolecularSurfaceFactoryRegistry.h>
49 #include <U2Algorithm/MsaColorScheme.h>
50 #include <U2Algorithm/MsaHighlightingScheme.h>
51 #ifdef OPENCL_SUPPORT
52 # include <U2Algorithm/OpenCLGpuRegistry.h>
53 #endif
54 #include <U2Algorithm/PWMConversionAlgorithmRegistry.h>
55 #include <U2Algorithm/PhyTreeGeneratorRegistry.h>
56 #include <U2Algorithm/RepeatFinderTaskFactoryRegistry.h>
57 #include <U2Algorithm/SWMulAlignResultNamesTagsRegistry.h>
58 #include <U2Algorithm/SWResultFilterRegistry.h>
59 #include <U2Algorithm/SecStructPredictAlgRegistry.h>
60 #include <U2Algorithm/SequenceContentFilterTask.h>
61 #include <U2Algorithm/SmithWatermanTaskFactoryRegistry.h>
62 #include <U2Algorithm/SplicedAlignmentTaskRegistry.h>
63 #include <U2Algorithm/StructuralAlignmentAlgorithmRegistry.h>
64 #include <U2Algorithm/SubstMatrixRegistry.h>
65
66 #include <U2Core/AnnotationSettings.h>
67 #include <U2Core/AppFileStorage.h>
68 #include <U2Core/AutoAnnotationsSupport.h>
69 #include <U2Core/CMDLineCoreOptions.h>
70 #include <U2Core/CMDLineRegistry.h>
71 #include <U2Core/CMDLineUtils.h>
72 #include <U2Core/Counter.h>
73 #include <U2Core/DBXRefRegistry.h>
74 #include <U2Core/DNAAlphabetRegistryImpl.h>
75 #include <U2Core/DNATranslation.h>
76 #include <U2Core/DataBaseRegistry.h>
77 #include <U2Core/DataPathRegistry.h>
78 #include <U2Core/ExternalToolRegistry.h>
79 #include <U2Core/FileAndDirectoryUtils.h>
80 #include <U2Core/GObjectTypes.h>
81 #include <U2Core/GUrlUtils.h>
82 #include <U2Core/LoadRemoteDocumentTask.h>
83 #include <U2Core/Log.h>
84 #include <U2Core/LogCache.h>
85 #include <U2Core/PasswordStorage.h>
86 #include <U2Core/ProjectFilterTaskRegistry.h>
87 #include <U2Core/ResourceTracker.h>
88 #include <U2Core/ScriptingToolRegistry.h>
89 #include <U2Core/TaskStarter.h>
90 #include <U2Core/Timer.h>
91 #include <U2Core/TmpDirChecker.h>
92 #include <U2Core/U2DbiRegistry.h>
93 #include <U2Core/UdrSchemaRegistry.h>
94 #include <U2Core/UserActionsWriter.h>
95 #include <U2Core/UserApplicationsSettings.h>
96 #include <U2Core/VirtualFileSystem.h>
97
98 #include <U2Designer/DashboardInfoRegistry.h>
99
100 #include <U2Formats/ConvertFileTask.h>
101 #include <U2Formats/DocumentFormatUtils.h>
102
103 #include <U2Gui/CredentialsAskerGui.h>
104 #include <U2Gui/FeatureKeyFilterTask.h>
105 #include <U2Gui/ImportWidgetsFactories.h>
106 #include <U2Gui/LogView.h>
107 #include <U2Gui/MsaContentFilterTask.h>
108 #include <U2Gui/MsaSeqNameFilterTask.h>
109 #include <U2Gui/OPWidgetFactoryRegistry.h>
110 #include <U2Gui/ObjectNameFilterTask.h>
111 #include <U2Gui/ObjectViewModel.h>
112 #include <U2Gui/PasteController.h>
113 #include <U2Gui/SequenceAccFilterTask.h>
114 #include <U2Gui/TextContentFilterTask.h>
115 #include <U2Gui/ToolsMenu.h>
116
117 #include <U2Lang/LocalDomain.h>
118 #include <U2Lang/QueryDesignerRegistry.h>
119 #include <U2Lang/WorkflowEnvImpl.h>
120 #include <U2Lang/WorkflowSettings.h>
121
122 #include <U2Test/GTestFrameworkComponents.h>
123 #include <U2Test/XMLTestFormat.h>
124
125 #include <U2View/AnnotHighlightWidgetFactory.h>
126 #include <U2View/AssemblyInfoWidget.h>
127 #include <U2View/AssemblyNavigationWidget.h>
128 #include <U2View/AssemblySettingsWidget.h>
129 #include <U2View/ColorSchemaSettingsController.h>
130 #include <U2View/DnaAssemblyUtils.h>
131 #include <U2View/FindPatternMsaWidgetFactory.h>
132 #include <U2View/FindPatternWidgetFactory.h>
133 #include <U2View/MSAGeneralTabFactory.h>
134 #include <U2View/MSAHighlightingTabFactory.h>
135 #include <U2View/MaExportConsensusTabFactory.h>
136 #include <U2View/McaGeneralTabFactory.h>
137 #include <U2View/McaReadsTabFactory.h>
138 #include <U2View/PairAlignFactory.h>
139 #include <U2View/RefSeqCommonWidget.h>
140 #include <U2View/SeqStatisticsWidgetFactory.h>
141 #include <U2View/SequenceInfoFactory.h>
142 #include <U2View/TreeOptionsWidgetFactory.h>
143
144 // U2Private imports
145 #include <AppContextImpl.h>
146 #include <AppSettingsImpl.h>
147 #include <DocumentFormatRegistryImpl.h>
148 #include <IOAdapterRegistryImpl.h>
149 #include <PluginSupportImpl.h>
150 #include <ServiceRegistryImpl.h>
151 #include <SettingsImpl.h>
152 #include <TaskSchedulerImpl.h>
153 //#include <crash_handler/CrashHandler.h>
154
155 #include <U2Core/BundleInfo.h>
156
157 #include "app_settings/AppSettingsGUIImpl.h"
158 #include "app_settings/logview_settings/LogSettingsGUIController.h"
159 #include "main_window/CheckUpdatesTask.h"
160 #include "main_window/MainWindowImpl.h"
161 #include "main_window/ProxyStyle.h"
162 #include "main_window/SplashScreen.h"
163 #include "plugin_viewer/PluginViewerImpl.h"
164 #include "project_support/ProjectLoaderImpl.h"
165 #include "project_support/ProjectTasksGui.h"
166 #include "project_view/ProjectViewImpl.h"
167 #include "shtirlitz/Shtirlitz.h"
168 #include "task_view/TaskViewController.h"
169 #include "update/UgeneUpdater.h"
170 #include "welcome_page/WelcomePageMdiController.h"
171
172 using namespace U2;
173
174 #ifdef Q_OS_WIN
175 typedef BOOL(WINAPI *LPFN_ISWOW64PROCESS)(HANDLE, PBOOL);
176
177 LPFN_ISWOW64PROCESS fnIsWow64Process;
178
IsWow64()179 BOOL IsWow64() {
180 BOOL bIsWow64 = FALSE;
181
182 // IsWow64Process is not available on all supported versions of Windows.
183 // Use GetModuleHandle to get a handle to the DLL that contains the function
184 // and GetProcAddress to get a pointer to the function if available.
185
186 fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(
187 GetModuleHandle(TEXT("kernel32")), "IsWow64Process");
188
189 if (nullptr != fnIsWow64Process) {
190 if (!fnIsWow64Process(GetCurrentProcess(), &bIsWow64)) {
191 // handle error
192 }
193 }
194 return bIsWow64;
195 }
196 #endif // Q_OS_WIN
197
registerCoreServices()198 static void registerCoreServices() {
199 ServiceRegistry *sr = AppContext::getServiceRegistry();
200 TaskScheduler *ts = AppContext::getTaskScheduler();
201 ts->registerTopLevelTask(sr->registerServiceTask(new PluginViewerImpl()));
202 ts->registerTopLevelTask(sr->registerServiceTask(new ProjectViewImpl()));
203 }
204
setDataSearchPaths()205 static void setDataSearchPaths() {
206 // set search paths for data files
207 QStringList dataSearchPaths;
208 const static char *RELATIVE_DATA_DIR = "/data";
209 const static char *RELATIVE_DEV_DATA_DIR = "/../../data";
210 // on windows data is normally located in the application folder
211 QString appDirPath = AppContext::getWorkingDirectoryPath();
212 if (QDir(appDirPath + RELATIVE_DATA_DIR).exists()) {
213 dataSearchPaths.push_back(appDirPath + RELATIVE_DATA_DIR);
214 } else if (QDir(appDirPath + RELATIVE_DEV_DATA_DIR).exists()) { // data location for developers
215 dataSearchPaths.push_back(appDirPath + RELATIVE_DEV_DATA_DIR);
216 #ifdef Q_OS_DARWIN
217 } else {
218 QString dataDir = BundleInfo::getDataSearchPath();
219 if (!dataDir.isEmpty()) {
220 dataSearchPaths.push_back(dataDir);
221 }
222 #endif
223 }
224
225 #if (defined(Q_OS_UNIX)) && defined(UGENE_DATA_DIR)
226 // using folder which is set during installation process on Linux
227 QString ugene_data_dir(UGENE_DATA_DIR);
228 if (QDir(ugene_data_dir).exists()) {
229 dataSearchPaths.push_back(QString(UGENE_DATA_DIR));
230 }
231 #endif
232
233 if (dataSearchPaths.empty()) {
234 dataSearchPaths.push_back("/");
235 }
236
237 QDir::setSearchPaths(PATH_PREFIX_DATA, dataSearchPaths);
238 // now data files may be opened using QFile( "data:some_data_file" )
239 }
240
setSearchPaths()241 static void setSearchPaths() {
242 setDataSearchPaths();
243 }
244
initLogsCache(LogCacheExt & logsCache,const QStringList &)245 static void initLogsCache(LogCacheExt &logsCache, const QStringList &) {
246 #ifdef _DEBUG
247 logsCache.setConsoleOutputEnabled(true);
248 #else
249 QString consoleOutVal = qgetenv("UGENE_PRINT_TO_CONSOLE");
250 logsCache.setConsoleOutputEnabled(consoleOutVal == "true" || consoleOutVal == "1");
251 #endif
252 QString file = qgetenv(U2_PRINT_TO_FILE);
253 if (!file.isEmpty()) {
254 logsCache.setFileOutputEnabled(file);
255 return;
256 }
257 LogSettings ls;
258 ls.reinitAll();
259
260 #ifdef UGENE_FORCE_WRITE_LOG_TO_FILE
261 // It should be defined during the UGENE building.
262 // It is to force log writing for user's personal packages to avoid explaining how to write the log to file
263 // Add to DEFINES when you execute qmake for the project
264 ls.toFile = true;
265 const QString logsDir = AppContext::getAppSettings()->getUserAppsSettings()->getDefaultDataDirPath() + "/logs";
266 QDir().mkpath(logsDir);
267 ls.outputFile = logsDir + "/ugene_log_" + QDateTime::currentDateTime().toString("yyyy.MM.dd_hh-mm") + ".txt";
268 #endif
269
270 if (ls.toFile) {
271 logsCache.setFileOutputEnabled(ls.outputFile);
272 }
273 }
guiTestMessageOutput(QtMsgType type,const QMessageLogContext & context,const QString & msg)274 void guiTestMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg) {
275 Q_UNUSED(context)
276 switch (type) {
277 case QtDebugMsg:
278 uiLog.trace(msg);
279 break;
280 case QtWarningMsg:
281 uiLog.details(msg);
282 break;
283 case QtCriticalMsg:
284 uiLog.error(msg);
285 break;
286 case QtFatalMsg:
287 uiLog.error(msg);
288 abort();
289 default:
290 uiLog.trace(msg);
291 break;
292 }
293 }
initOptionsPanels()294 static void initOptionsPanels() {
295 OPWidgetFactoryRegistry *opWidgetFactoryRegistry = AppContext::getOPWidgetFactoryRegistry();
296 OPCommonWidgetFactoryRegistry *opCommonWidgetFactoryRegistry = AppContext::getOPCommonWidgetFactoryRegistry();
297
298 // Sequence View groups
299 opWidgetFactoryRegistry->registerFactory(new FindPatternWidgetFactory());
300 opWidgetFactoryRegistry->registerFactory(new AnnotHighlightWidgetFactory());
301 opWidgetFactoryRegistry->registerFactory(new SequenceInfoFactory());
302
303 // Assembly Browser groups
304 opWidgetFactoryRegistry->registerFactory(new AssemblyNavigationWidgetFactory());
305 opWidgetFactoryRegistry->registerFactory(new AssemblyInfoWidgetFactory());
306 opWidgetFactoryRegistry->registerFactory(new AssemblySettingsWidgetFactory());
307
308 // MSA groups
309 MSAGeneralTabFactory *msaGeneralTabFactory = new MSAGeneralTabFactory();
310 QString msaGeneralId = msaGeneralTabFactory->getOPGroupParameters().getGroupId();
311 opWidgetFactoryRegistry->registerFactory(msaGeneralTabFactory);
312 opWidgetFactoryRegistry->registerFactory(new FindPatternMsaWidgetFactory());
313
314 MSAHighlightingFactory *msaHighlightingFactory = new MSAHighlightingFactory();
315 QString msaHighlightingId = msaHighlightingFactory->getOPGroupParameters().getGroupId();
316 opWidgetFactoryRegistry->registerFactory(msaHighlightingFactory);
317
318 opWidgetFactoryRegistry->registerFactory(new PairAlignFactory());
319 opWidgetFactoryRegistry->registerFactory(new MSATreeOptionsWidgetFactory());
320 opWidgetFactoryRegistry->registerFactory(new AddTreeWidgetFactory());
321 opWidgetFactoryRegistry->registerFactory(new MsaExportConsensusTabFactory());
322
323 SeqStatisticsWidgetFactory *msaSeqStatisticvsFactory = new SeqStatisticsWidgetFactory();
324 QString msaSeqStatisticsId = msaSeqStatisticvsFactory->getOPGroupParameters().getGroupId();
325 opWidgetFactoryRegistry->registerFactory(msaSeqStatisticvsFactory);
326
327 // MSA common widgets
328 QList<QString> groupIds;
329 groupIds << msaHighlightingId << msaSeqStatisticsId << msaGeneralId;
330 RefSeqCommonWidgetFactory *refSeqCommonWidget = new RefSeqCommonWidgetFactory(groupIds);
331 opCommonWidgetFactoryRegistry->registerFactory(refSeqCommonWidget);
332
333 // Tree View groups
334 opWidgetFactoryRegistry->registerFactory(new TreeOptionsWidgetFactory());
335
336 // MCA groups
337 opWidgetFactoryRegistry->registerFactory(new McaGeneralTabFactory());
338 opWidgetFactoryRegistry->registerFactory(new McaExportConsensusTabFactory());
339 opWidgetFactoryRegistry->registerFactory(new McaReadsTabFactory());
340 }
341
initProjectFilterTaskRegistry()342 static void initProjectFilterTaskRegistry() {
343 ProjectFilterTaskRegistry *registry = AppContext::getProjectFilterTaskRegistry();
344
345 registry->registerTaskFactory(new ObjectNameFilterTaskFactory);
346 registry->registerTaskFactory(new MsaSeqNameFilterTaskFactory);
347 registry->registerTaskFactory(new MsaContentFilterTaskFactory);
348 registry->registerTaskFactory(new McaReadNameFilterTaskFactory);
349 registry->registerTaskFactory(new McaReferenceNameFilterTaskFactory);
350 registry->registerTaskFactory(new McaReadContentFilterTaskFactory);
351 registry->registerTaskFactory(new McaReferenceContentFilterTaskFactory);
352 registry->registerTaskFactory(new SequenceContentFilterTaskFactory);
353 registry->registerTaskFactory(new TextContentFilterTaskFactory);
354 registry->registerTaskFactory(new SequenceAccFilterTaskFactory);
355 registry->registerTaskFactory(new FeatureKeyFilterTaskFactory);
356 }
357
358 class GApplication : public QApplication {
359 public:
GApplication(int & argc,char ** argv)360 GApplication(int &argc, char **argv)
361 : QApplication(argc, argv) {
362 }
363
event(QEvent * event)364 bool event(QEvent *event) {
365 if (QEvent::FileOpen == event->type()) {
366 QStringList urls(static_cast<QFileOpenEvent *>(event)->file());
367 openAfterPluginsLoaded(urls);
368 return true;
369 }
370 return QApplication::event(event);
371 }
372
openAfterPluginsLoaded(const QStringList & urls,TaskStarter::StartCondition condition=TaskStarter::NoCondition)373 void openAfterPluginsLoaded(const QStringList &urls, TaskStarter::StartCondition condition = TaskStarter::NoCondition) {
374 OpenWithProjectTask *task = new OpenWithProjectTask(urls);
375
376 TaskStarter *taskStarter = new TaskStarter(task, condition);
377 if (AppContext::getMainWindow()->getQMainWindow()->isVisible()) {
378 taskStarter->registerTask();
379 } else {
380 connect(AppContext::getMainWindow(), SIGNAL(si_show()), taskStarter, SLOT(registerTask()));
381 }
382 }
383 };
384
findKey(const QStringList & envList,const QString & key)385 static QString findKey(const QStringList &envList, const QString &key) {
386 QString prefix = key + "=";
387 QString result;
388 foreach (const QString &var, envList) {
389 if (var.startsWith(prefix)) {
390 result = var.mid(prefix.length());
391 break;
392 }
393 }
394 return result;
395 }
396
397 namespace {
398 #ifdef Q_OS_DARWIN
fixMacFonts()399 void fixMacFonts() {
400 if (QSysInfo::MacintoshVersion > QSysInfo::MV_10_8) {
401 // fix Mac OS X 10.9 (mavericks) font issue
402 // https://bugreports.qt-project.org/browse/QTBUG-32789
403 // the solution is taken from http://successfulsoftware.net/2013/10/23/fixing-qt-4-for-mac-os-x-10-9-mavericks/
404 QFont::insertSubstitution(".Lucida Grande UI", "Lucida Grande");
405 }
406 }
407 #endif
408 } // namespace
409
main(int argc,char ** argv)410 int main(int argc, char **argv) {
411 #if 0
412 if (CrashHandler::isEnabled()) {
413 CrashHandler::setupHandler();
414 }
415
416 if (qgetenv(ENV_SEND_CRASH_REPORTS) == "0") {
417 CrashHandler::setSendCrashReports(false);
418 }
419 #endif
420
421 QT_REQUIRE_VERSION(argc, argv, QT_VERSION_STR);
422
423 GTIMER(c1, t1, "main()->QApp::exec");
424
425 #ifdef Q_OS_DARWIN
426 fixMacFonts();
427
428 // A workaround for https://bugreports.qt.io/browse/QTBUG-87014: "Qt application gets stuck trying to open main window under Big Sur"
429 qputenv("QT_MAC_WANTS_LAYER", "1");
430 #endif
431
432 // QApplication app(argc, argv);
433 GApplication app(argc, argv);
434
435 #ifdef Q_OS_UNIX
436 QPixmap pixmap(":/ugene/images/originals/ugene_128.png");
437 app.setWindowIcon(pixmap);
438 #endif
439
440 QMainWindow window;
441 SplashScreen *splashScreen = new SplashScreen(&window);
442 splashScreen->adjustSize();
443 splashScreen->setGeometry(
444 QStyle::alignedRect(
445 Qt::LeftToRight,
446 Qt::AlignCenter,
447 splashScreen->size(),
448 qApp->desktop()->availableGeometry(QApplication::desktop()->primaryScreen())));
449 splashScreen->show();
450
451 AppContextImpl *appContext = AppContextImpl::getApplicationContext();
452 appContext->setGUIMode(true);
453 appContext->setWorkingDirectoryPath(QCoreApplication::applicationDirPath());
454
455 QCoreApplication::addLibraryPath(AppContext::getWorkingDirectoryPath());
456
457 // add some extra paths used during development
458 #ifdef Q_OS_WIN
459 # ifdef _DEBUG
460 QString devPluginsPath = QDir(AppContext::getWorkingDirectoryPath() + "/../../extras/windows/dotnet_style/_debug").absolutePath();
461 # else
462 QString devPluginsPath = QDir(AppContext::getWorkingDirectoryPath() + "/../../extras/windows/dotnet_style/_release").absolutePath();
463 # endif
464 QCoreApplication::addLibraryPath(devPluginsPath); // dev version
465 #endif
466
467 setSearchPaths();
468
469 // parse all cmdline arguments
470 CMDLineRegistry *cmdLineRegistry = new CMDLineRegistry(app.arguments());
471 appContext->setCMDLineRegistry(cmdLineRegistry);
472
473 // 1 create settings
474 SettingsImpl *globalSettings = new SettingsImpl(QSettings::SystemScope);
475 appContext->setGlobalSettings(globalSettings);
476
477 SettingsImpl *settings = new SettingsImpl(QSettings::UserScope);
478 appContext->setSettings(settings);
479
480 AppSettings *appSettings = new AppSettingsImpl();
481 appContext->setAppSettings(appSettings);
482
483 UserAppsSettings *userAppSettings = AppContext::getAppSettings()->getUserAppsSettings();
484
485 if (cmdLineRegistry->hasParameter(CMDLineCoreOptions::DOWNLOAD_DIR)) {
486 userAppSettings->setDownloadDirPath(FileAndDirectoryUtils::getAbsolutePath(cmdLineRegistry->getParameterValue(CMDLineCoreOptions::DOWNLOAD_DIR)));
487 }
488 if (cmdLineRegistry->hasParameter(CMDLineCoreOptions::CUSTOM_TOOLS_CONFIG_DIR)) {
489 userAppSettings->setCustomToolsConfigsDirPath(FileAndDirectoryUtils::getAbsolutePath(cmdLineRegistry->getParameterValue(CMDLineCoreOptions::CUSTOM_TOOLS_CONFIG_DIR)));
490 }
491 if (cmdLineRegistry->hasParameter(CMDLineCoreOptions::TMP_DIR)) {
492 userAppSettings->setUserTemporaryDirPath(FileAndDirectoryUtils::getAbsolutePath(cmdLineRegistry->getParameterValue(CMDLineCoreOptions::TMP_DIR)));
493 }
494 if (cmdLineRegistry->hasParameter(CMDLineCoreOptions::DEFAULT_DATA_DIR)) {
495 userAppSettings->setDefaultDataDirPath(FileAndDirectoryUtils::getAbsolutePath(cmdLineRegistry->getParameterValue(CMDLineCoreOptions::DEFAULT_DATA_DIR)));
496 }
497 if (cmdLineRegistry->hasParameter(CMDLineCoreOptions::FILE_STORAGE_DIR)) {
498 userAppSettings->setFileStorageDir(FileAndDirectoryUtils::getAbsolutePath(cmdLineRegistry->getParameterValue(CMDLineCoreOptions::FILE_STORAGE_DIR)));
499 }
500
501 // Set translations if needed: use value in the settings or environment variables to override.
502 // The default case 'en' does not need any files: the values for this locale are hardcoded in the code.
503 QTranslator translator;
504 QStringList failedToLoadTranslatorFiles; // List of translators file names tried but failed to load/not found.
505
506 // The file specified by user has the highest priority in the translations lookup order.
507 QStringList envList = QProcess::systemEnvironment();
508 QString envTranslationFile = findKey(envList, "UGENE_TRANSLATION_FILE");
509 if (envTranslationFile.isEmpty() || !translator.load(envTranslationFile)) {
510 if (!envTranslationFile.isEmpty()) {
511 failedToLoadTranslatorFiles << envTranslationFile;
512 }
513 QStringList translationFileList = {
514 "transl_" + findKey(envList, "UGENE_TRANSLATION"),
515 userAppSettings->getTranslationFile(),
516 "transl_" + QLocale::system().name().left(2).toLower(),
517 BundleInfo::getExtraTranslationSearchPath(cmdLineRegistry)};
518 // Keep only valid entries.
519 translationFileList.removeAll("");
520 translationFileList.removeAll("transl_");
521 translationFileList.removeDuplicates();
522 // Use the first translation from the list that works.
523 for (const QString &translationFile : qAsConst(translationFileList)) {
524 if (translationFile == "transl_en" || translator.load(translationFile, AppContext::getWorkingDirectoryPath())) {
525 break;
526 }
527 failedToLoadTranslatorFiles << translationFile;
528 }
529 }
530 if (!translator.isEmpty()) {
531 QCoreApplication::installTranslator(&translator);
532 GObjectTypes::initTypeTranslations();
533 }
534 GObjectTypes::initTypeIcons();
535
536 ToolsMenu::init();
537
538 // 3 create functional components of ugene
539 LogCacheExt logsCache;
540 initLogsCache(logsCache, envList);
541 LogCache::setAppGlobalInstance(&logsCache);
542 app.installEventFilter(new UserActionsWriter());
543 coreLog.details(UserAppsSettings::tr("UGENE initialization started"));
544 for (const QString &fileName : failedToLoadTranslatorFiles) {
545 coreLog.trace(QObject::tr("Translation file not found: %1").arg(fileName));
546 }
547
548 int ugeneArch = getUgeneBinaryArch();
549 QString ugeneArchCounterSuffix = ugeneArch == UGENE_ARCH_X86_64 ? "Ugene 64-bit"
550 : ugeneArch == UGENE_ARCH_X86_32 ? "Ugene 32-bit"
551 : "Undetected architecture";
552 GCounter::increment("UGENE architecture", ugeneArchCounterSuffix);
553
554 QString osArchCounterSuffix = isOsWindows() ? "Windows"
555 : isOsMac() ? "MacOS"
556 : isOsLinux() ? "Linux"
557 : isOsUnix() ? "Unix"
558 : "Undetected OS";
559 #if defined Q_OS_WIN
560 if (ugeneArch == UGENE_ARCH_X86_64 || IsWow64()) {
561 osArchCounterSuffix += " 64-bit";
562 } else {
563 osArchCounterSuffix += " 32-bit";
564 }
565 #elif defined Q_OS_DARWIN
566 osArchCounterSuffix += " 64-bit";
567 #else
568 QString currentCpuArchitecture = QSysInfo::currentCpuArchitecture();
569 if (currentCpuArchitecture.contains("64")) {
570 osArchCounterSuffix += " 64-bit";
571 } else if (currentCpuArchitecture.contains("32")) {
572 osArchCounterSuffix += " 32-bit";
573 }
574 #endif
575 GCounter::increment("OS architecture", osArchCounterSuffix);
576
577 coreLog.trace(QString("UGENE run at dir %1 with parameters %2").arg(AppContext::getWorkingDirectoryPath()).arg(app.arguments().join(" ")));
578
579 // print some settings info, can't do it earlier than logging is initialized
580 coreLog.trace(QString("Active UGENE.ini file : %1").arg(AppContext::getSettings()->fileName()));
581
582 qInstallMessageHandler(guiTestMessageOutput);
583
584 #if defined(Q_OS_UNIX)
585 if (envList.indexOf("UGENE_GUI_TEST=1") >= 0) {
586 QApplication::setAttribute(Qt::AA_DontUseNativeMenuBar);
587 }
588 #endif
589 QString styleName = userAppSettings->getVisualStyle();
590 QStyle *qtStyle = nullptr;
591 if (!styleName.isEmpty()) {
592 qtStyle = QStyleFactory::create(styleName);
593 if (qtStyle == nullptr) {
594 uiLog.details(AppContextImpl::tr("Style not available %1").arg(styleName));
595 }
596 }
597 auto proxyStyle = new ProxyStyle(qtStyle);
598 // Re-use the original style object name, because it is saved in the settings as a part of 'User preferences'.
599 if (qtStyle != nullptr) {
600 proxyStyle->setObjectName(qtStyle->objectName());
601 }
602 QApplication::setStyle(proxyStyle);
603
604 ResourceTracker *resTrack = new ResourceTracker();
605 appContext->setResourceTracker(resTrack);
606
607 TaskSchedulerImpl *ts = new TaskSchedulerImpl(appSettings->getAppResourcePool());
608 appContext->setTaskScheduler(ts);
609
610 AnnotationSettingsRegistry *asr = new AnnotationSettingsRegistry(DocumentFormatUtils::predefinedSettings());
611 appContext->setAnnotationSettingsRegistry(asr);
612
613 TestFramework *tf = new TestFramework();
614 appContext->setTestFramework(tf);
615
616 GTestFormatRegistry *tfr = AppContext::getTestFramework()->getTestFormatRegistry();
617 XMLTestFormat *xmlTestFormat = qobject_cast<XMLTestFormat *>(tfr->findFormat("XML"));
618 QList<XMLTestFactory *> fs = ProjectTests::createTestFactories();
619 foreach (XMLTestFactory *f, fs) {
620 bool res = xmlTestFormat->registerTestFactory(f);
621 assert(res);
622 Q_UNUSED(res);
623 }
624
625 MainWindowImpl *mw = new MainWindowImpl();
626 appContext->setMainWindow(mw);
627 mw->prepare();
628 #ifdef Q_OS_DARWIN
629 // TODO: need to check for other OS and remove #ifdef
630 if (cmdLineRegistry->hasParameter(CMDLineCoreOptions::LAUNCH_GUI_TEST) || cmdLineRegistry->hasParameter(CMDLineCoreOptions::LAUNCH_GUI_TEST_BATCH)) {
631 mw->getQMainWindow()->menuBar()->setNativeMenuBar(false);
632 }
633 if (cmdLineRegistry->hasParameter(CMDLineCoreOptions::DONT_USE_NATIVE_MENUBAR)) {
634 if (cmdLineRegistry->getParameterValue(CMDLineCoreOptions::DONT_USE_NATIVE_MENUBAR) == "0") {
635 mw->getQMainWindow()->menuBar()->setNativeMenuBar(true);
636 } else {
637 mw->getQMainWindow()->menuBar()->setNativeMenuBar(false);
638 }
639 }
640 #endif
641 QObject::connect(UgeneUpdater::getInstance(), SIGNAL(si_update()), mw, SLOT(sl_exitAction()));
642
643 AppSettingsGUI *appSettingsGUI = new AppSettingsGUIImpl();
644 appContext->setAppSettingsGUI(appSettingsGUI);
645
646 AppContext::getMainWindow()->getDockManager()->registerDock(MWDockArea_Bottom, new TaskViewDockWidget(), QKeySequence(Qt::ALT | Qt::Key_2));
647
648 // Initialize logged log view
649 LogViewWidget *logView = new LogViewWidget(&logsCache);
650 logView->setObjectName(DOCK_LOG_VIEW);
651 AppContext::getAppSettingsGUI()->registerPage(new LogSettingsPageController(logView));
652 AppContext::getMainWindow()->getDockManager()->registerDock(MWDockArea_Bottom, logView, QKeySequence(Qt::ALT | Qt::Key_3));
653
654 GObjectViewFactoryRegistry *ovfr = new GObjectViewFactoryRegistry();
655 appContext->setObjectViewFactoryRegistry(ovfr);
656
657 UdrSchemaRegistry *schemaRegistry = new UdrSchemaRegistry();
658 appContext->setUdrSchemaRegistry(schemaRegistry);
659
660 U2DbiRegistry *dbiRegistry = new U2DbiRegistry();
661 appContext->setDbiRegistry(dbiRegistry);
662
663 DocumentFormatRegistryImpl *dfr = new DocumentFormatRegistryImpl();
664 appContext->setDocumentFormatRegistry(dfr);
665 ImportWidgetsFactories::registerFactories();
666
667 IOAdapterRegistryImpl *io = new IOAdapterRegistryImpl();
668 appContext->setIOAdapterRegistry(io);
669
670 DNATranslationRegistry *dtr = new DNATranslationRegistry();
671 appContext->setDNATranslationRegistry(dtr);
672
673 DNAAlphabetRegistry *dal = new DNAAlphabetRegistryImpl(dtr);
674 appContext->setDNAAlphabetRegistry(dal);
675
676 DBXRefRegistry *dbxr = new DBXRefRegistry();
677 appContext->setDBXRefRegistry(dbxr);
678
679 MsaColorSchemeRegistry *mcsr = new MsaColorSchemeRegistry();
680 appContext->setMsaColorSchemeRegistry(mcsr);
681
682 AppContext::getAppSettingsGUI()->registerPage(new ColorSchemaSettingsPageController(mcsr));
683
684 MsaHighlightingSchemeRegistry *mhsr = new MsaHighlightingSchemeRegistry();
685 appContext->setMsaHighlightingSchemeRegistry(mhsr);
686
687 MSAConsensusAlgorithmRegistry *msaConsReg = new MSAConsensusAlgorithmRegistry();
688 appContext->setMSAConsensusAlgorithmRegistry(msaConsReg);
689
690 AssemblyConsensusAlgorithmRegistry *assemblyConsReg = new AssemblyConsensusAlgorithmRegistry();
691 appContext->setAssemblyConsensusAlgorithmRegistry(assemblyConsReg);
692
693 MSADistanceAlgorithmRegistry *msaDistReg = new MSADistanceAlgorithmRegistry();
694 appContext->setMSADistanceAlgorithmRegistry(msaDistReg);
695
696 PWMConversionAlgorithmRegistry *pwmConvReg = new PWMConversionAlgorithmRegistry();
697 appContext->setPWMConversionAlgorithmRegistry(pwmConvReg);
698
699 SubstMatrixRegistry *smr = new SubstMatrixRegistry();
700 appContext->setSubstMatrixRegistry(smr);
701
702 SmithWatermanTaskFactoryRegistry *swar = new SmithWatermanTaskFactoryRegistry();
703 appContext->setSmithWatermanTaskFactoryRegistry(swar);
704
705 SWMulAlignResultNamesTagsRegistry *swmarntr = new SWMulAlignResultNamesTagsRegistry();
706 appContext->setSWMulAlignResultNamesTagsRegistry(swmarntr);
707
708 RepeatFinderTaskFactoryRegistry *rfr = new RepeatFinderTaskFactoryRegistry();
709 appContext->setRepeatFinderTaskFactoryRegistry(rfr);
710
711 ScriptingToolRegistry *str = new ScriptingToolRegistry();
712 appContext->setScriptingToolRegistry(str);
713
714 ExternalToolRegistry *etr = new ExternalToolRegistry();
715 appContext->setExternalToolRegistry(etr);
716
717 QDActorPrototypeRegistry *qpr = new QDActorPrototypeRegistry();
718 appContext->setQDActorFactoryRegistry(qpr);
719
720 CDSearchFactoryRegistry *cdsfr = new CDSearchFactoryRegistry();
721 appContext->setCDSearchFactoryRegistry(cdsfr);
722
723 StructuralAlignmentAlgorithmRegistry *saar = new StructuralAlignmentAlgorithmRegistry();
724 appContext->setStructuralAlignmentAlgorithmRegistry(saar);
725
726 PhyTreeGeneratorRegistry *genRegistry = new PhyTreeGeneratorRegistry();
727 appContext->setPhyTreeGeneratorRegistry(genRegistry);
728
729 MolecularSurfaceFactoryRegistry *msfr = new MolecularSurfaceFactoryRegistry();
730 appContext->setMolecularSurfaceFactoryRegistry(msfr);
731
732 SWResultFilterRegistry *swrfr = new SWResultFilterRegistry();
733 appContext->setSWResultFilterRegistry(swrfr);
734
735 SecStructPredictAlgRegistry *sspar = new SecStructPredictAlgRegistry();
736 appContext->setSecStructPedictAlgRegistry(sspar);
737
738 CudaGpuRegistry *cgr = new CudaGpuRegistry();
739 appContext->setCudaGpuRegistry(cgr);
740
741 #ifdef OPENCL_SUPPORT
742 OpenCLGpuRegistry *oclgr = new OpenCLGpuRegistry();
743 appContext->setOpenCLGpuRegistry(oclgr);
744 #endif
745
746 VirtualFileSystemRegistry *vfsReg = new VirtualFileSystemRegistry();
747 appContext->setVirtualFileSystemRegistry(vfsReg);
748
749 DnaAssemblyAlgRegistry *assemblyReg = new DnaAssemblyAlgRegistry();
750 appContext->setDnaAssemblyAlgRegistry(assemblyReg);
751
752 GenomeAssemblyAlgRegistry *genomeAssemblyReg = new GenomeAssemblyAlgRegistry();
753 appContext->setGenomeAssemblyAlgRegistry(genomeAssemblyReg);
754
755 DnaAssemblySupport assemblySupport;
756 Q_UNUSED(assemblySupport);
757
758 DataBaseRegistry *dbr = new DataBaseRegistry();
759 appContext->setDataBaseRegistry(dbr);
760
761 SplicedAlignmentTaskRegistry *splicedAlignmentTaskRegistiry = new SplicedAlignmentTaskRegistry();
762 appContext->setSplicedAlignmentTaskRegistry(splicedAlignmentTaskRegistiry);
763
764 OPWidgetFactoryRegistry *opWidgetFactoryRegistry = new OPWidgetFactoryRegistry();
765 appContext->setOPWidgetFactoryRegistry(opWidgetFactoryRegistry);
766
767 OPCommonWidgetFactoryRegistry *opCommonWidgetFactoryRegistry = new OPCommonWidgetFactoryRegistry();
768 appContext->setOPCommonWidgetFactoryRegistry(opCommonWidgetFactoryRegistry);
769
770 WorkflowScriptRegistry *workflowScriptRegistry = new WorkflowScriptRegistry();
771 appContext->setWorkflowScriptRegistry(workflowScriptRegistry);
772
773 AlignmentAlgorithmsRegistry *alignmentAlgorithmsRegistry = new AlignmentAlgorithmsRegistry();
774 appContext->setAlignmentAlgorithmsRegistry(alignmentAlgorithmsRegistry);
775
776 U2DataPathRegistry *dpr = new U2DataPathRegistry();
777 appContext->setDataPathRegistry(dpr);
778
779 CredentialsAsker *credentialsAsker = new CredentialsAskerGui();
780 appContext->setCredentialsAsker(credentialsAsker);
781
782 PasswordStorage *passwordStorage = new PasswordStorage();
783 appContext->setPasswordStorage(passwordStorage);
784 AppSettingsImpl::addPublicDbCredentials2Settings();
785
786 ConvertFactoryRegistry *convertFactoryRegistry = new ConvertFactoryRegistry();
787 appContext->setConvertFactoryRegistry(convertFactoryRegistry);
788
789 IdRegistry<WelcomePageAction> *welcomePageActions = new IdRegistry<WelcomePageAction>();
790 appContext->setWelcomePageActionRegistry(welcomePageActions);
791
792 ProjectFilterTaskRegistry *projectFilterTaskRegistry = new ProjectFilterTaskRegistry;
793 appContext->setProjectFilterTaskRegistry(projectFilterTaskRegistry);
794 initProjectFilterTaskRegistry();
795
796 PasteFactory *pasteFactory = new PasteFactoryImpl;
797 appContext->setPasteFactory(pasteFactory);
798
799 DashboardInfoRegistry *dashboardInfoRegistry = new DashboardInfoRegistry;
800 appContext->setDashboardInfoRegistry(dashboardInfoRegistry);
801
802 Workflow::WorkflowEnv::init(new Workflow::WorkflowEnvImpl());
803 Workflow::WorkflowEnv::getDomainRegistry()->registerEntry(new LocalWorkflow::LocalDomainFactory());
804
805 ServiceRegistryImpl *sreg = new ServiceRegistryImpl();
806 appContext->setServiceRegistry(sreg);
807
808 PluginSupportImpl *psp = new PluginSupportImpl();
809 appContext->setPluginSupport(psp);
810
811 ProjectLoaderImpl *pli = new ProjectLoaderImpl();
812 appContext->setProjectLoader(pli);
813 QObject::connect(mw, SIGNAL(si_paste()), pli, SLOT(sl_paste()));
814
815 CMDLineUtils::init();
816
817 RecentlyDownloadedCache *rdc = new RecentlyDownloadedCache();
818 appContext->setRecentlyDownloadedCache(rdc);
819
820 AutoAnnotationsSupport *aaSupport = new AutoAnnotationsSupport();
821 appContext->setAutoAnnotationsSupport(aaSupport);
822
823 AppFileStorage *appFileStorage = new AppFileStorage();
824 U2OpStatusImpl os;
825 appFileStorage->init(os);
826 if (os.hasError()) {
827 coreLog.error(os.getError());
828 delete appFileStorage;
829 } else {
830 appContext->setAppFileStorage(appFileStorage);
831 }
832
833 // Register all Options Panel groups on the required GObjectViews
834 initOptionsPanels();
835
836 QStringList urls = CMDLineRegistryUtils::getPureValues();
837
838 if (urls.isEmpty() && AppContext::getAppSettings()->getUserAppsSettings()->openLastProjectAtStartup()) {
839 QString lastProject = ProjectLoaderImpl::getLastProjectURL();
840 if (!lastProject.isEmpty()) {
841 urls << lastProject;
842 }
843 }
844
845 if (!urls.isEmpty()) {
846 // defer loading until all plugins/services loaded
847 app.openAfterPluginsLoaded(urls, TaskStarter::NoProject);
848 }
849
850 registerCoreServices();
851
852 GCOUNTER(cvar, "ugeneui launch");
853
854 // 3 run QT GUI
855 t1.stop();
856
857 // coreLog.info(AppContextImpl::tr("%1-bit version of UGENE started").arg(Version::appArchitecture));
858 Version v = Version::appVersion();
859 coreLog.info(QObject::tr("UGENE started"));
860 coreLog.info(QObject::tr("UGENE version: %1 %2-bit").arg(v.text).arg(Version::appArchitecture));
861
862 QObject::connect(ts, SIGNAL(si_ugeneIsReadyToWork()), splashScreen, SLOT(sl_close()));
863 QObject::connect(ts, SIGNAL(si_ugeneIsReadyToWork()), mw, SLOT(sl_show()));
864
865 WelcomePageMdiController *wpc = new WelcomePageMdiController();
866 QObject::connect(ts, SIGNAL(si_ugeneIsReadyToWork()), wpc, SLOT(sl_showPage()));
867 QObject::connect(mw, SIGNAL(si_showWelcomePage()), wpc, SLOT(sl_showPage()));
868 QObject::connect(pli, SIGNAL(si_recentListChanged()), wpc, SLOT(sl_onRecentChanged()));
869
870 QList<Task *> tasks;
871
872 if (UgeneUpdater::isEnabled() && qgetenv("UGENE_GUI_TEST").toInt() != 1) {
873 tasks << new CheckUpdatesTask(true);
874
875 TmpDirChecker *tempDirChecker = new TmpDirChecker;
876 tasks << tempDirChecker;
877 QObject::connect(tempDirChecker, SIGNAL(si_checkFailed(QString)), mw, SLOT(sl_tempDirPathCheckFailed(QString)));
878 }
879 if (!envList.contains(ENV_UGENE_DEV + QString("=1"))) {
880 tasks << new ShtirlitzStartupTask();
881 }
882
883 mw->registerStartupChecks(tasks);
884
885 MemoryLocker l(160, AppResource::SystemMemory); // 100Mb on UGENE start, ~60Mb SQLite cache
886 int rc = app.exec();
887 l.release();
888
889 // 4 deallocate resources
890 if (!envList.contains(ENV_UGENE_DEV + QString("=1"))) {
891 Shtirlitz::saveGatheredInfo();
892 }
893
894 delete wpc;
895
896 appContext->setDashboardInfoRegistry(nullptr);
897 delete dashboardInfoRegistry;
898
899 appContext->setPasteFactory(nullptr);
900 delete pasteFactory;
901
902 appContext->setProjectFilterTaskRegistry(nullptr);
903 delete projectFilterTaskRegistry;
904
905 appContext->setRecentlyDownloadedCache(nullptr);
906 delete rdc;
907
908 appContext->setProjectLoader(nullptr);
909 delete pli;
910
911 appContext->setPluginSupport(nullptr);
912 delete psp;
913
914 appContext->setServiceRegistry(nullptr);
915 delete sreg;
916
917 Workflow::WorkflowEnv::shutdown();
918
919 appContext->setCredentialsAsker(nullptr);
920 delete credentialsAsker;
921
922 appContext->setPasswordStorage(nullptr);
923 delete passwordStorage;
924
925 appContext->setDataPathRegistry(nullptr);
926 delete dpr;
927
928 appContext->setAlignmentAlgorithmsRegistry(nullptr);
929 delete alignmentAlgorithmsRegistry;
930
931 appContext->setWorkflowScriptRegistry(nullptr);
932 delete workflowScriptRegistry;
933
934 appContext->setOPCommonWidgetFactoryRegistry(nullptr);
935 delete opCommonWidgetFactoryRegistry;
936
937 appContext->setOPWidgetFactoryRegistry(nullptr);
938 delete opWidgetFactoryRegistry;
939
940 appContext->setSplicedAlignmentTaskRegistry(nullptr);
941 delete splicedAlignmentTaskRegistiry;
942
943 appContext->setDataBaseRegistry(nullptr);
944 delete dbr;
945
946 appContext->setDnaAssemblyAlgRegistry(nullptr);
947 delete assemblyReg;
948
949 appContext->setVirtualFileSystemRegistry(nullptr);
950 delete vfsReg;
951
952 #ifdef OPENCL_SUPPORT
953 appContext->setOpenCLGpuRegistry(nullptr);
954 delete oclgr;
955 #endif
956
957 appContext->setCudaGpuRegistry(nullptr);
958 delete cgr;
959
960 appContext->setSecStructPedictAlgRegistry(nullptr);
961 delete sspar;
962
963 appContext->setWelcomePageActionRegistry(nullptr);
964 delete welcomePageActions;
965
966 appContext->setConvertFactoryRegistry(nullptr);
967 delete convertFactoryRegistry;
968
969 appContext->setSWResultFilterRegistry(nullptr);
970 delete swrfr;
971
972 appContext->setMolecularSurfaceFactoryRegistry(nullptr);
973 delete msfr;
974
975 appContext->setPhyTreeGeneratorRegistry(nullptr);
976 delete genRegistry;
977
978 appContext->setStructuralAlignmentAlgorithmRegistry(nullptr);
979 delete saar;
980
981 appContext->setCDSearchFactoryRegistry(nullptr);
982 delete cdsfr;
983
984 appContext->setQDActorFactoryRegistry(nullptr);
985 delete qpr;
986
987 appContext->setExternalToolRegistry(nullptr);
988 delete etr;
989
990 appContext->setScriptingToolRegistry(nullptr);
991 delete str;
992
993 appContext->setRepeatFinderTaskFactoryRegistry(nullptr);
994 delete rfr;
995
996 appContext->setSWMulAlignResultNamesTagsRegistry(nullptr);
997 delete swmarntr;
998
999 appContext->setSmithWatermanTaskFactoryRegistry(nullptr);
1000 delete swar;
1001
1002 appContext->setSubstMatrixRegistry(nullptr);
1003 delete smr;
1004
1005 appContext->setPWMConversionAlgorithmRegistry(nullptr);
1006 delete pwmConvReg;
1007
1008 appContext->setMSADistanceAlgorithmRegistry(nullptr);
1009 delete msaDistReg;
1010
1011 appContext->setAssemblyConsensusAlgorithmRegistry(nullptr);
1012 delete assemblyConsReg;
1013
1014 appContext->setMSAConsensusAlgorithmRegistry(nullptr);
1015 delete msaConsReg;
1016
1017 appContext->setMsaHighlightingSchemeRegistry(nullptr);
1018 delete mhsr;
1019
1020 appContext->setMsaColorSchemeRegistry(nullptr);
1021 delete mcsr;
1022
1023 appContext->setDBXRefRegistry(nullptr);
1024 delete dbxr;
1025
1026 appContext->setDNAAlphabetRegistry(nullptr);
1027 delete dal;
1028
1029 appContext->setDNATranslationRegistry(nullptr);
1030 delete dtr;
1031
1032 appContext->setIOAdapterRegistry(nullptr);
1033 delete io;
1034
1035 appContext->setDocumentFormatRegistry(nullptr);
1036 delete dfr;
1037
1038 delete dbiRegistry;
1039 appContext->setDbiRegistry(nullptr);
1040
1041 appContext->setUdrSchemaRegistry(nullptr);
1042 delete schemaRegistry;
1043
1044 appContext->setObjectViewFactoryRegistry(nullptr);
1045 delete ovfr;
1046
1047 appContext->setAnnotationSettingsRegistry(nullptr);
1048 delete asr;
1049
1050 appContext->setCMDLineRegistry(nullptr);
1051 delete cmdLineRegistry;
1052
1053 appContext->setMainWindow(nullptr);
1054 delete mw;
1055
1056 appContext->setTestFramework(nullptr);
1057 delete tf;
1058
1059 appContext->setTaskScheduler(nullptr);
1060 delete ts;
1061
1062 appContext->setResourceTracker(nullptr);
1063 delete resTrack;
1064
1065 appContext->setAutoAnnotationsSupport(nullptr);
1066 delete aaSupport;
1067
1068 bool deleteSettingsFile = userAppSettings->resetSettings();
1069 QString iniFile = AppContext::getSettings()->fileName();
1070
1071 appContext->setAppSettingsGUI(nullptr);
1072 delete appSettingsGUI;
1073
1074 appContext->setAppSettings(nullptr);
1075 delete appSettings;
1076
1077 appContext->setSettings(nullptr);
1078 delete settings;
1079
1080 appContext->setGlobalSettings(nullptr);
1081 delete globalSettings;
1082
1083 if (deleteSettingsFile) {
1084 #ifndef Q_OS_DARWIN
1085 QFile ff;
1086 ff.remove(iniFile);
1087 #else
1088 ResetSettingsMac::reset();
1089 #endif // !Q_OS_DARWIN
1090 }
1091
1092 UgeneUpdater::onClose();
1093 //CrashHandler::shutdown();
1094
1095 return rc;
1096 }
1097