Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. The problem with exception handle in QML 2 plugin
Forum Update on Monday, May 27th 2025

The problem with exception handle in QML 2 plugin

Scheduled Pinned Locked Moved QML and Qt Quick
1 Posts 1 Posters 1.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    shav
    wrote on 22 May 2013, 12:08 last edited by
    #1

    Hi everyone!

    I have the QML 2 plugin with method which crashed. I try to add the try..catch block for method but the catch section not called when method generating exception this is how to look my method:
    @
    QString MdlLogParser::description(QString prefix)
    {
    try
    {
    QString res = prefix + "MdlLogParser (Object)\n";
    QString newPrefix = "| ";

        QString subPrefix = prefix + newPrefix;
    
        res.append(prefix + newPrefix + QString("logContent = %1\n").arg(m_logContent));
        res.append(prefix + newPrefix + QString("logFilePath = %1\n").arg(m_logFilePath));
        res.append(prefix + newPrefix + QString("version = %1\n").arg(m_version));
    
        if(m_loggerInfo != NULL)
        {
            res.append(m_loggerInfo->description(subPrefix));
        }
        else
        {
            res.append(prefix + newPrefix + QString("loggerInfo = NULL\n"));
        }
    
        if(m_deviceInfo != NULL)
        {
            res.append(m_deviceInfo->description(subPrefix));
        }
        else
        {
            res.append(prefix + newPrefix + QString("deviceInfo = NULL\n"));
        }
    
        if(m_appInfo != NULL)
        {
            res.append(m_appInfo->description(subPrefix));
        }
        else
        {
            res.append(prefix + newPrefix + QString("appInfo = NULL\n"));
        }
    
        res.append(m_crashLog->description(subPrefix)); //generating exception because m_crashLog is NULL. I fix this when add the if(m_crashLog == NULL). The method description(subPrefix) for object m_crashLog have try...catch too.
    
        if(m_error != NULL)
        {
            res.append(m_error->description(subPrefix));
        }
        else
        {
            res.append(prefix + newPrefix + QString("error = NULL\n"));
        }
    
        res.append(prefix + newPrefix + QString("methods (Array)\n"));
        foreach(MdlLogMethod* method, m_methods)
        {
            res.append(method->description(subPrefix + newPrefix));
        }
        res.append(prefix + newPrefix + QString("methods\n"));
        res.append(prefix + newPrefix + QString("classes (Array)\n"));
        foreach(MdlLogClass* classObj, m_classes)
        {
            res.append(classObj->description(subPrefix + newPrefix));
        }
        res.append(prefix + newPrefix + QString("classes\n"));
        res.append(prefix + newPrefix + QString("messages (Array)\n"));
        foreach(MdlLogMessage* msg, m_messages)
        {
            res.append(msg->description(subPrefix + newPrefix));
        }
        res.append(prefix + newPrefix + QString("messages\n"));
        res.append(prefix + newPrefix + QString("systemMessage (Array)\n"));
        foreach(MdlLogMessage* msg, m_systemMessage)
        {
            res.append(msg->description(subPrefix + newPrefix));
        }
        res.append(prefix + newPrefix + QString("systemMessage\n"));
        res.append(prefix + newPrefix + QString("images (Array)\n"));
        foreach(MdlLogImage* img, m_images)
        {
            res.append(img->description(subPrefix + newPrefix));
        }
        res.append(prefix + newPrefix + QString("images\n"));
        res.append(prefix + newPrefix + QString("sessions (Array)\n"));
        foreach(MdlLogSession* session, m_sessions)
        {
            res.append(session->description(subPrefix + newPrefix));
        }
        res.append(prefix + newPrefix + QString("sessions\n"));
        if(m_methodsInformer != NULL)
        {
            res.append(m_methodsInformer->description(prefix + newPrefix));
        }
        else
        {
            res.append(prefix + newPrefix + QString("methodsInformer = NULL\n"));
        }
        res.append(prefix + "MdlLogParser\n");
    
        return res;
    }
    catch(std::exception& exception)
    {
        qDebug()<<"Exception: "<<exception.what();
        return prefix+"NULL\n";
    }
    

    }
    @

    Can you tell me what I do wrong? Thanks for any help!

    Mac OS and iOS Developer

    1 Reply Last reply
    0

    1/1

    22 May 2013, 12:08

    • Login

    • Login or register to search.
    1 out of 1
    • First post
      1/1
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved