Changeset View
Changeset View
Standalone View
Standalone View
debugjob.cpp
Show First 20 Lines • Show All 257 Lines • ▼ Show 20 Line(s) | |||||
258 | } | 258 | } | ||
259 | 259 | | |||
260 | void XDebugJob::processError(QProcess::ProcessError error) | 260 | void XDebugJob::processError(QProcess::ProcessError error) | ||
261 | { | 261 | { | ||
262 | if (error == QProcess::FailedToStart) { | 262 | if (error == QProcess::FailedToStart) { | ||
263 | setError(-1); | 263 | setError(-1); | ||
264 | QString errmsg = i18n("Could not start program '%1'. Make sure that the " | 264 | QString errmsg = i18n("Could not start program '%1'. Make sure that the " | ||
265 | "path is specified correctly.", m_proc->property("executable").toString()); | 265 | "path is specified correctly.", m_proc->property("executable").toString()); | ||
266 | KMessageBox::error(KDevelop::ICore::self()->uiController()->activeMainWindow(), errmsg, i18n("Could not start application")); | | |||
267 | setErrorText(errmsg); | 266 | setErrorText(errmsg); | ||
268 | emitResult(); | 267 | emitResult(); | ||
269 | } | 268 | } | ||
270 | qDebug() << "Process error"; | 269 | qDebug() << "Process error"; | ||
271 | 270 | | |||
272 | if (m_session && m_session->connection()) { | 271 | if (m_session && m_session->connection()) { | ||
273 | m_session->connection()->setState(DebugSession::EndedState); | 272 | m_session->connection()->setState(DebugSession::EndedState); | ||
274 | } | 273 | } | ||
274 | else if(m_session) | ||||
275 | { | ||||
276 | m_session->stateChanged(DebugSession::EndedState); | ||||
277 | m_session->stopDebugger(); | ||||
278 | } | ||||
275 | } | 279 | } | ||
276 | 280 | | |||
277 | void XDebugJob::appendLine(const QString& l) | 281 | void XDebugJob::appendLine(const QString& l) | ||
278 | { | 282 | { | ||
279 | if (KDevelop::OutputModel* m = model()) { | 283 | if (KDevelop::OutputModel* m = model()) { | ||
280 | m->appendLine(l); | 284 | m->appendLine(l); | ||
281 | } | 285 | } | ||
282 | } | 286 | } | ||
283 | 287 | | |||
284 | KDevelop::OutputModel* XDebugJob::model() | 288 | KDevelop::OutputModel* XDebugJob::model() | ||
285 | { | 289 | { | ||
286 | return dynamic_cast<KDevelop::OutputModel*>(KDevelop::OutputJob::model()); | 290 | return dynamic_cast<KDevelop::OutputModel*>(KDevelop::OutputJob::model()); | ||
287 | } | 291 | } | ||
288 | 292 | | |||
289 | XDebugBrowserJob::XDebugBrowserJob(DebugSession* session, KDevelop::ILaunchConfiguration* cfg, QObject* parent) | 293 | XDebugBrowserJob::XDebugBrowserJob(DebugSession* session, KDevelop::ILaunchConfiguration* cfg, QObject* parent) | ||
290 | : KJob(parent) | 294 | : KJob(parent) | ||
291 | , m_session(session) | 295 | , m_session(session) | ||
292 | { | 296 | { | ||
293 | setCapabilities(Killable); | 297 | setCapabilities(Killable); | ||
294 | 298 | | |||
295 | session->setLaunchConfiguration(cfg); | 299 | session->setLaunchConfiguration(cfg); | ||
296 | 300 | | |||
301 | setObjectName(cfg->name()); | ||||
302 | | ||||
297 | IExecuteBrowserPlugin* iface = KDevelop::ICore::self()->pluginController() | 303 | IExecuteBrowserPlugin* iface = KDevelop::ICore::self()->pluginController() | ||
298 | ->pluginForExtension("org.kdevelop.IExecuteBrowserPlugin")->extension<IExecuteBrowserPlugin>(); | 304 | ->pluginForExtension("org.kdevelop.IExecuteBrowserPlugin")->extension<IExecuteBrowserPlugin>(); | ||
299 | Q_ASSERT(iface); | 305 | Q_ASSERT(iface); | ||
300 | 306 | | |||
301 | QString err; | 307 | QString err; | ||
302 | m_url = iface->url(cfg, err); | 308 | m_url = iface->url(cfg, err); | ||
303 | if (!err.isEmpty()) { | 309 | if (!err.isEmpty()) { | ||
304 | m_url.clear(); | 310 | m_url.clear(); | ||
Show All 31 Lines | 325 | { | |||
336 | url.setQuery("XDEBUG_SESSION_START=kdev"); | 342 | url.setQuery("XDEBUG_SESSION_START=kdev"); | ||
337 | if (m_browser.isEmpty()) { | 343 | if (m_browser.isEmpty()) { | ||
338 | if (!QDesktopServices::openUrl(url)) { | 344 | if (!QDesktopServices::openUrl(url)) { | ||
339 | qWarning() << "openUrl failed, something went wrong when creating the job"; | 345 | qWarning() << "openUrl failed, something went wrong when creating the job"; | ||
340 | emitResult(); | 346 | emitResult(); | ||
341 | } | 347 | } | ||
342 | } else { | 348 | } else { | ||
343 | KProcess proc(this); | 349 | KProcess proc(this); | ||
350 | | ||||
344 | proc.setProgram(QStringList() << m_browser << url.url()); | 351 | proc.setProgram(QStringList() << m_browser << url.url()); | ||
345 | proc.execute(); | 352 | if( !proc.startDetached() ) | ||
353 | { | ||||
354 | processFailedToStart(); | ||||
355 | } | ||||
356 | } | ||||
357 | } | ||||
brauch: where do you connect to this slot ...? It seems like it is only ever called explicitly with… | |||||
358 | | ||||
359 | | ||||
brauch: use qCWarning / qCDebug | |||||
360 | void XDebugBrowserJob::processFailedToStart() | ||||
361 | { | ||||
362 | qWarning() << "Cannot start application" << m_browser; | ||||
363 | setError(-1); | ||||
364 | QString errmsg = i18n("Could not start program '%1'. Make sure that the " | ||||
365 | "path is specified correctly.", m_browser); | ||||
366 | setErrorText(errmsg); | ||||
346 | emitResult(); | 367 | emitResult(); | ||
368 | qDebug() << "Process error"; | ||||
369 | | ||||
370 | if (m_session && m_session->connection()) { | ||||
371 | m_session->connection()->setState(DebugSession::EndedState); | ||||
372 | } | ||||
373 | else if(m_session) | ||||
374 | { | ||||
375 | m_session->stateChanged(DebugSession::EndedState); | ||||
376 | m_session->stopDebugger(); | ||||
347 | } | 377 | } | ||
348 | } | 378 | } | ||
349 | 379 | | |||
350 | bool XDebugBrowserJob::doKill() | 380 | bool XDebugBrowserJob::doKill() | ||
351 | { | 381 | { | ||
352 | qDebug(); | 382 | qDebug(); | ||
353 | m_session->stopDebugger(); | 383 | m_session->stopDebugger(); | ||
354 | QUrl url = m_url; | 384 | QUrl url = m_url; | ||
355 | url.setQuery("XDEBUG_SESSION_STOP_NO_EXEC=kdev"); | 385 | url.setQuery("XDEBUG_SESSION_STOP_NO_EXEC=kdev"); | ||
356 | QDesktopServices::openUrl(url); | 386 | QDesktopServices::openUrl(url); | ||
357 | return true; | 387 | return true; | ||
358 | } | 388 | } | ||
359 | 389 | | |||
360 | void XDebugBrowserJob::sessionFinished() | 390 | void XDebugBrowserJob::sessionFinished() | ||
361 | { | 391 | { | ||
362 | emitResult(); | 392 | emitResult(); | ||
363 | } | 393 | } | ||
394 | | ||||
364 | } | 395 | } |
where do you connect to this slot ...? It seems like it is only ever called explicitly with QProcess::FailedToStart as the error, which is a bit unintuitive.