https://bugs.kde.org/show_bug.cgi?id=452558

            Bug ID: 452558
           Summary: Spectacle silently dismisses errors raised by purpose
                    sharing plugins
           Product: Spectacle
           Version: 21.04.3
          Platform: unspecified
                OS: Linux
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: General
          Assignee: m...@baloneygeek.com
          Reporter: kde_b...@mydayyy.eu
                CC: k...@david-redondo.de
  Target Milestone: ---

SUMMARY

For sharing images to my private image hosting service, I created a purpose
plugins which in some instances can raise errors. Currently, spectacle silently
dismisses any raised error.

This is how I raise an error:

setError(HttpError);
setErrorText(QString::fromUtf8("Received HTTP Error: ") + statusCode);
emitResult();

where is correctly defined as as a value greater than UserDefinedError:
    enum {
        InvalidFoo = UserDefinedError,
        GenericError,
        NotConnectedError,
        UnknownMimeError,
        WalletFailure,
        HttpError,
    };

I believe the issue dates back to a commit from 3 years ago:
https://phabricator.kde.org/D22042

Since error is a boolean, the added code here always silently swallows the
error, it will never enter the if (error) at line 419.

I believe the needed change here is to make error an integer which would fit
the KJob error enum:
    enum {
        /*** Indicates there is no error */
        NoError = 0,
        /*** Indicates the job was killed */
        KilledJobError = 1,
        /*** Subclasses should define error codes starting at this value */
        UserDefinedError = 100,
    };

This would also need to be changed in the function void
ExportMenu::loadPurposeMenu, which receives the error as an integer from the
purpose plugin and passes it on as a boolean:

    connect(mPurposeMenu, &Purpose::Menu::finished, this, [this](const
QJsonObject &output, int error, const QString &message) {
        if (error) {
            Q_EMIT imageShared(true, message);
        } else {
            Q_EMIT imageShared(false,
output[QStringLiteral("url")].toString());
        }
    });

STEPS TO REPRODUCE
1. Share an image via spectacle using a plugin which raises an error via
emitResult()

OBSERVED RESULT
No error is raised, the error is silently swallowed.

EXPECTED RESULT
An inline message is shown with the appropriate error message (line 415 in the
above commit)

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 5.24.2
KDE Frameworks Version: 5.91.0
Qt Version:  5.15.2

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to