Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-61834

Example containing errors

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 5.11.2
    • 5.9.0
    • Documentation, Purchasing
    • None

    Description

      In : https://doc.qt.io/qt-5/qtpurchasing-gettingstarted-cpp.html

      The example code for the following function :

      void MyApplication::handleTransaction(QInAppTransaction *transaction)
      

      contains if statement with parentheses that are not closed :

      if (!hasAlreadyStoredTransaction(transaction->orderId()) {
      

      and also here :

      if (!addHealthPotionToPersistentStorage(transaction->orderId())
      

      there is also a semicolon missing:

      popupErrorDialog(tr("Unable to write to persistent storage. Please make sure there is sufficient space and restart."))
      

      here is the full example :

      void MyApplication::handleTransaction(QInAppTransaction *transaction)
      {
          if (transaction->status() == QInAppTransaction::PurchaseApproved
              && transaction->product()->identifier() == QStringLiteral("healthPotion")) {
              if (!hasAlreadyStoredTransaction(transaction->orderId()) {
                  ++m_healthPotions;
                  if (!addHealthPotionToPersistentStorage(transaction->orderId())
                      popupErrorDialog(tr("Unable to write to persistent storage. Please make sure there is sufficient space and restart."))
                  else
                      transaction->finalize();
              }
          } else if (transaction->status() == QInAppTransaction::PurchaseFailed) {
              popupErrorDialog(tr("Purchase not completed."));
              transaction->finalize();
          }
      }
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            paulwicking Paul Wicking
            theshadowx Ali Diouri
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes