Bug 417107 - QCoreApplication::applicationDirPath: Please instantiate the QApplication object first
Summary: QCoreApplication::applicationDirPath: Please instantiate the QApplication obj...
Status: RESOLVED FIXED
Alias: None
Product: krusader
Classification: Applications
Component: general (show other bugs)
Version: 2.7.2
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Krusader Bugs Distribution List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-02-03 15:06 UTC by Erik Quaeghebeur
Modified: 2020-04-15 22:46 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Erik Quaeghebeur 2020-02-03 15:06:52 UTC
SUMMARY
In my logs, I get the following warning:

krusader[8982]: QCoreApplication::applicationDirPath: Please instantiate the QApplication object first

I assume that this means some part of the code must be fixed somewhat.

SOFTWARE/OS VERSIONS
KDE Plasma Version: 5.17.4
KDE Frameworks Version: 5.64.0
Qt Version: 5.13.2
Comment 1 Toni Asensi Esteve 2020-02-08 00:01:25 UTC
Hello, Eric. It doesn't happen to me using the latest git version of Krusader. If you can follow the steps of
    https://commits.kde.org/krusader?path=INSTALL
then you can build Krusader, get the latest features, and tell Krusader developers about what you find.
Comment 2 Erik Quaeghebeur 2020-02-08 20:42:16 UTC
(In reply to Toni Asensi Esteve from comment #1)
> […] It doesn't happen to me using the latest git version of Krusader.

Thanks for testing. I'll wait for the next release, as this is not breaking anything for me. You can close as WORKSFORME if you wish.
Comment 3 Toni Asensi Esteve 2020-02-12 21:47:03 UTC
Hi, Eric, the "QCoreApplication::applicationDirPath: Please instantiate the QApplication object first" message wasn't seen in my logs, nor in my normal use, nor in my tests, using Kubuntu 18.04 (with Qt 5.9.5), nor Ubuntu 16.04 LTS (after having installed Qt 5.9.9 manually); although the message is seen when testing under Kubuntu 19.10 (with Qt 5.12.4), executing Krusader from the command line.

A possible solution is not easy to find, for example I replaced the content of the main.cpp file of Krusader with only that text:
    
    # include <QDebug>

    int main()
    {
        qDebug() << "1----" << endl;
        exit(0);
    }
and I did some changes in order to make Krusader build [^1], I compiled and installed Krusader, but its execution still showed:
    QCoreApplication::applicationDirPath: Please instantiate the QApplication object first
    1---- 
    
    
[^1]: diff --git a/krusader/Archive/abstractthreadedjob.cpp b/krusader/Archive/abstractthreadedjob.cpp
    index 928a3b32..47569725 100644
    --- a/krusader/Archive/abstractthreadedjob.cpp
    +++ b/krusader/Archive/abstractthreadedjob.cpp
    @@ -650,13 +650,13 @@ bool AbstractJobThread::getArchiveInformation(QString &path, QString &type, QStr
        QMimeType mt = db.mimeTypeForUrl(url);
        QString mime = mt.isValid() ? mt.name() : QString();
        bool encrypted = false;
    -    type = arcHandler.getType(encrypted, path, mime);
    +//    type = arcHandler.getType(encrypted, path, mime);
    
    -    // Check that the archive is supported
    -    if (!KRarcHandler::arcSupported(type)) {
    -        sendError(KIO::ERR_NO_CONTENT, i18nc("%1=archive filename", "%1, unsupported archive type.", arcName));
    -        return false;
    -    }
    +//    // Check that the archive is supported
    +//    if (!KRarcHandler::arcSupported(type)) {
    +//        sendError(KIO::ERR_NO_CONTENT, i18nc("%1=archive filename", "%1, unsupported archive type.", arcName));
    +//        return false;
    +//    }
    
        password = encrypted ? getPassword(path) : QString();
    
    diff --git a/krusader/FileSystem/filesearcher.cpp b/krusader/FileSystem/filesearcher.cpp
    index 9e28fb9e..46cad36e 100644
    --- a/krusader/FileSystem/filesearcher.cpp
    +++ b/krusader/FileSystem/filesearcher.cpp
    @@ -138,12 +138,12 @@ void FileSearcher::scanDirectory(const QUrl &url)
                // query search in archive; NOTE: only supported for local files
                QUrl archiveURL = fileUrl;
                bool encrypted;
    -            const QString type = arcHandler.getType(encrypted, fileUrl.path(), fileItem->getMime());
    +//            const QString type = arcHandler.getType(encrypted, fileUrl.path(), fileItem->getMime());

    -            if (!encrypted) {
    -                archiveURL.setScheme(TAR_TYPES.contains(type) ? "tar" : "krarc");
    -                m_unScannedUrls.push(archiveURL);
    -            }
    +//            if (!encrypted) {
    +//                archiveURL.setScheme(TAR_TYPES.contains(type) ? "tar" : "krarc");
    +//                m_unScannedUrls.push(archiveURL);
    +//            }
Comment 4 Toni Asensi Esteve 2020-03-30 20:56:37 UTC
There's a proposed solution in https://phabricator.kde.org/D28413
Comment 5 Toni Asensi Esteve 2020-04-15 22:46:15 UTC
Git commit 2f168d23c20d69f00d733ca970a49096b1ab0782 by Toni Asensi Esteve.
Committed on 15/04/2020 at 22:38.
Pushed by asensi into branch 'master'.

Archives: Solve the 'QCoreApplication::applicationDirPath: Please instantiate the QApplication object first' error

Solve the «QCoreApplication::applicationDirPath: Please instantiate the QApplication object first» error, what required moving code.

Besides, after the code of the `generateKrarcArchiveMimetypes()` function was moved to a constructor, that code is executed only once and the source code ends up being simplified. Make the KrServices class simpler by moving archive-related code to an archive-related class.

Test plan: The one described in the task [Solve some bugs related to archives, remove some duplicated code](https://phabricator.kde.org/T12876).

FIXED: [ 417107 ] QCoreApplication::applicationDirPath: Please instantiate the QApplication object first

Differential Revision: https://phabricator.kde.org/D28413

M  +1    -1    krArc/krarcbasemanager.cpp
M  +1    -3    krusader/Archive/abstractthreadedjob.cpp
M  +72   -0    krusader/Archive/krarchandler.cpp
M  +14   -0    krusader/Archive/krarchandler.h
M  +0    -2    krusader/Archive/packjob.cpp
M  +2    -1    krusader/Konfigurator/kgprotocols.cpp
M  +1    -1    krusader/Panel/panelfunc.cpp
M  +2    -3    krusader/Search/krsearchmod.cpp
M  +1    -0    krusader/krglobal.cpp
M  +3    -0    krusader/krglobal.h
M  +5    -82   krusader/krservices.cpp
M  +0    -6    krusader/krservices.h
M  +4    -0    krusader/krusader.cpp
M  +0    -3    krusader/main.cpp

https://commits.kde.org/krusader/2f168d23c20d69f00d733ca970a49096b1ab0782