Changeset View
Changeset View
Standalone View
Standalone View
src/drkonqi.cpp
Show First 20 Lines • Show All 75 Lines • ▼ Show 20 Line(s) | |||||
76 | { | 76 | { | ||
77 | delete m_systemInformation; | 77 | delete m_systemInformation; | ||
78 | delete m_backend; | 78 | delete m_backend; | ||
79 | } | 79 | } | ||
80 | 80 | | |||
81 | //static | 81 | //static | ||
82 | DrKonqi *DrKonqi::instance() | 82 | DrKonqi *DrKonqi::instance() | ||
83 | { | 83 | { | ||
84 | static DrKonqi *drKonqiInstance = nullptr; | 84 | static DrKonqi drKonqiInstance; | ||
85 | if (!drKonqiInstance) { | 85 | return &drKonqiInstance; | ||
broulik: +1 | |||||
86 | drKonqiInstance = new DrKonqi(); | | |||
87 | } | | |||
88 | return drKonqiInstance; | | |||
89 | } | 86 | } | ||
90 | 87 | | |||
91 | //based on KCrashDelaySetHandler from kdeui/util/kcrash.cpp | 88 | //based on KCrashDelaySetHandler from kdeui/util/kcrash.cpp | ||
92 | class EnableCrashCatchingDelayed : public QObject | 89 | class EnableCrashCatchingDelayed : public QObject | ||
93 | { | 90 | { | ||
94 | public: | 91 | public: | ||
95 | EnableCrashCatchingDelayed() { | 92 | EnableCrashCatchingDelayed() { | ||
96 | startTimer(10000); // 10 s | 93 | startTimer(10000); // 10 s | ||
97 | } | 94 | } | ||
98 | protected: | 95 | protected: | ||
99 | void timerEvent(QTimerEvent *event) override { | 96 | void timerEvent(QTimerEvent *event) override { | ||
100 | qCDebug(DRKONQI_LOG) << "Enabling drkonqi crash catching"; | 97 | qCDebug(DRKONQI_LOG) << "Enabling drkonqi crash catching"; | ||
101 | KCrash::setDrKonqiEnabled(true); | 98 | KCrash::setDrKonqiEnabled(true); | ||
102 | killTimer(event->timerId()); | 99 | killTimer(event->timerId()); | ||
103 | this->deleteLater(); | 100 | this->deleteLater(); | ||
104 | } | 101 | } | ||
105 | }; | 102 | }; | ||
106 | 103 | | |||
107 | bool DrKonqi::init() | 104 | bool DrKonqi::init() | ||
108 | { | 105 | { | ||
109 | if (!instance()->m_backend->init()) { | 106 | if (!instance()->m_backend->init()) { | ||
110 | cleanup(); | | |||
111 | return false; | 107 | return false; | ||
112 | } else { //all ok, continue initialization | 108 | } else { //all ok, continue initialization | ||
113 | // Set drkonqi to handle its own crashes, but only if the crashed app | 109 | // Set drkonqi to handle its own crashes, but only if the crashed app | ||
114 | // is not drkonqi already. If it is drkonqi, delay enabling crash catching | 110 | // is not drkonqi already. If it is drkonqi, delay enabling crash catching | ||
115 | // to prevent recursive crashes (in case it crashes at startup) | 111 | // to prevent recursive crashes (in case it crashes at startup) | ||
116 | if (crashedApplication()->fakeExecutableBaseName() != QLatin1String("drkonqi")) { | 112 | if (crashedApplication()->fakeExecutableBaseName() != QLatin1String("drkonqi")) { | ||
117 | qCDebug(DRKONQI_LOG) << "Enabling drkonqi crash catching"; | 113 | qCDebug(DRKONQI_LOG) << "Enabling drkonqi crash catching"; | ||
118 | KCrash::setDrKonqiEnabled(true); | 114 | KCrash::setDrKonqiEnabled(true); | ||
119 | } else { | 115 | } else { | ||
120 | new EnableCrashCatchingDelayed; | 116 | new EnableCrashCatchingDelayed; | ||
121 | } | 117 | } | ||
122 | return true; | 118 | return true; | ||
123 | } | 119 | } | ||
124 | } | 120 | } | ||
125 | 121 | | |||
126 | void DrKonqi::cleanup() | | |||
127 | { | | |||
128 | delete instance(); | | |||
129 | } | | |||
130 | | ||||
131 | //static | 122 | //static | ||
132 | SystemInformation *DrKonqi::systemInformation() | 123 | SystemInformation *DrKonqi::systemInformation() | ||
133 | { | 124 | { | ||
134 | return instance()->m_systemInformation; | 125 | return instance()->m_systemInformation; | ||
135 | } | 126 | } | ||
136 | 127 | | |||
137 | //static | 128 | //static | ||
138 | DebuggerManager* DrKonqi::debuggerManager() | 129 | DebuggerManager* DrKonqi::debuggerManager() | ||
▲ Show 20 Lines • Show All 230 Lines • Show Last 20 Lines |
+1