Changeset View
Changeset View
Standalone View
Standalone View
src/widgets/krun.cpp
Show First 20 Lines • Show All 313 Lines • ▼ Show 20 Line(s) | 310 | { | |||
---|---|---|---|---|---|
314 | if (service && !service->entryPath().isEmpty() | 314 | if (service && !service->entryPath().isEmpty() | ||
315 | && !KDesktopFile::isAuthorizedDesktopFile(service->entryPath())) { | 315 | && !KDesktopFile::isAuthorizedDesktopFile(service->entryPath())) { | ||
316 | qCWarning(KIO_WIDGETS) << "No authorization to execute " << service->entryPath(); | 316 | qCWarning(KIO_WIDGETS) << "No authorization to execute " << service->entryPath(); | ||
317 | KMessageBox::sorry(window, i18n("You are not authorized to execute this file.")); | 317 | KMessageBox::sorry(window, i18n("You are not authorized to execute this file.")); | ||
318 | delete proc; | 318 | delete proc; | ||
319 | return 0; | 319 | return 0; | ||
320 | } | 320 | } | ||
321 | 321 | | |||
322 | // Don't proceed if we can't find the executable. | ||||
323 | if (!QFile(executable).exists() && QStandardPaths::findExecutable(executable).isEmpty()) { | ||||
324 | QEventLoopLocker locker; | ||||
325 | KMessageBox::sorry(nullptr, i18n("Could not find the program '%1'", executable)); | ||||
326 | delete proc; | ||||
327 | return 0; | ||||
328 | } | ||||
329 | | ||||
322 | QString bin = KIO::DesktopExecParser::executableName(executable); | 330 | QString bin = KIO::DesktopExecParser::executableName(executable); | ||
323 | #if HAVE_X11 // Startup notification doesn't work with QT/E, service isn't needed without Startup notification | 331 | #if HAVE_X11 // Startup notification doesn't work with QT/E, service isn't needed without Startup notification | ||
324 | static bool isX11 = QGuiApplication::platformName() == QStringLiteral("xcb"); | 332 | static bool isX11 = QGuiApplication::platformName() == QStringLiteral("xcb"); | ||
325 | if (isX11) { | 333 | if (isX11) { | ||
326 | bool silent; | 334 | bool silent; | ||
327 | QByteArray wmclass; | 335 | QByteArray wmclass; | ||
328 | KStartupInfoId id; | 336 | KStartupInfoId id; | ||
329 | bool startup_notify = (asn != "0" && KRun::checkStartupNotify(QString() /*unused*/, service, &silent, &wmclass)); | 337 | bool startup_notify = (asn != "0" && KRun::checkStartupNotify(QString() /*unused*/, service, &silent, &wmclass)); | ||
▲ Show 20 Lines • Show All 1267 Lines • ▼ Show 20 Line(s) | |||||
1597 | #endif | 1605 | #endif | ||
1598 | 1606 | | |||
1599 | } | 1607 | } | ||
1600 | 1608 | | |||
1601 | void | 1609 | void | ||
1602 | KProcessRunner::slotProcessExited(int exitCode, QProcess::ExitStatus exitStatus) | 1610 | KProcessRunner::slotProcessExited(int exitCode, QProcess::ExitStatus exitStatus) | ||
1603 | { | 1611 | { | ||
1604 | //qDebug() << m_executable << "exitCode=" << exitCode << "exitStatus=" << exitStatus; | 1612 | //qDebug() << m_executable << "exitCode=" << exitCode << "exitStatus=" << exitStatus; | ||
1605 | Q_UNUSED(exitStatus); | 1613 | Q_UNUSED(exitCode) | ||
1614 | Q_UNUSED(exitStatus) | ||||
1606 | 1615 | | |||
1607 | terminateStartupNotification(); // do this before the messagebox | 1616 | terminateStartupNotification(); // do this before the messagebox | ||
1608 | if (exitCode != 0 && !m_executable.isEmpty()) { | 1617 | | ||
dfaure: if (qGuiApp) { your code } else { qWarning }
so we don't eat a possible error message… | |||||
1609 | // Let's see if the error is because the exe doesn't exist. | | |||
1610 | // When this happens, waitForStarted returns false, but not if kioexec | | |||
1611 | // was involved, then we come here, that's why the code is here. | | |||
1612 | // | | |||
1613 | // We'll try to find the executable relatively to current directory, | | |||
1614 | // (or with a full path, if m_executable is absolute), and then in the PATH. | | |||
1615 | if (!QFile(m_executable).exists() && QStandardPaths::findExecutable(m_executable).isEmpty()) { | | |||
1616 | QEventLoopLocker locker; | | |||
1617 | KMessageBox::sorry(nullptr, i18n("Could not find the program '%1'", m_executable)); | | |||
1618 | } else { | | |||
1619 | //qDebug() << process->readAllStandardError(); | | |||
1620 | } | | |||
1621 | } | | |||
1622 | deleteLater(); | 1618 | deleteLater(); | ||
Actually, KMessageBox requires qApp, not just qGuiApp. (Then again, all of KRun requires widgets, so I'm not even sure when this could ever be null, currently) dfaure: Actually, KMessageBox requires qApp, not just qGuiApp.
(Then again, all of KRun requires… | |||||
1623 | } | 1619 | } | ||
1624 | 1620 | | |||
1625 | #include "moc_krun.cpp" | 1621 | #include "moc_krun.cpp" | ||
1626 | #include "moc_krun_p.cpp" | 1622 | #include "moc_krun_p.cpp" | ||
1627 | #include "krun.moc" | 1623 | #include "krun.moc" |
if (qGuiApp) { your code } else { qWarning }
so we don't eat a possible error message completely.
Looks OK otherwise.
[we have KDialogJobUiDelegate::showErrorMessage which implements a mesagebox queue, but that goes back to the issue of not having a job or a uidelegate in the first place]
[Every 5 years I'm thinking KRun should be a KJob, we just found another reason why...]