Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Photo crash on project switch #2880

Merged
merged 4 commits into from Oct 30, 2023
Merged

Photo crash on project switch #2880

merged 4 commits into from Oct 30, 2023

Conversation

PeterPetrik
Copy link
Contributor

@PeterPetrik PeterPetrik commented Oct 27, 2023

fix #2879

When testing on test simple QML project and our implementation StackView, it looks like
when stackView.clear() is called:

  • StackView.onRemoved is called first
  • Some signals are passed and evaluated (e.g. QGIS project is loaded, layer in featurelayerpair contains dangling pointer and in evaluateExpression it crashes)
  • Only after then Component.onDestruction is called

Therefore we need to remove all connections to layer/project/etc. we are about to unload from all existing forms (there should be only one in the stack) before calling clear()

Other chances in the C++ code are probably because we are passing FeatureLayerPair with nullptr layer to the attribute controller, so we should make sure it does not crash by dereferencing null layer pointer.

Sample QML code

import QtQuick
import QtQuick.Controls
import QtQuick.Window

Window {
  width: 640
  height: 480
  visible: true
  title: qsTr("Hello World")

  Row {
    anchors.fill: parent
    spacing: 2

  Button {
    text: "add"
    onClicked: stackView.push(formComponent)
  }

  Button {
    text: "clean"
    onClicked: stackView.clear()
  }

  StackView {

    height: 100
    width: 100

    id: stackView

    focus: true

    // anchors.fill: parent
  }

  Component {
    id: formComponent

    Rectangle {
      id: wrapper

      height:100
      width: 100
      color: "red"

      StackView.onRemoved: {
        console.log("*****StackView.onRemoved")
      }

      Component.onCompleted: {
        console.log("*****Created form")
      }

      Component.onDestruction: {
        console.log("*****Destroying form")
      }
    }
  }

  }


}

@PeterPetrik PeterPetrik changed the title photo crash on project switch WIP: photo crash on project switch Oct 27, 2023
@PeterPetrik PeterPetrik changed the title WIP: photo crash on project switch Photo crash on project switch Oct 27, 2023
@PeterPetrik PeterPetrik added data corruption - sync failure - crash - anr The most critical classification ready-for-testing Ready to be tested by testers crew - passed review by devs labels Oct 27, 2023
@PeterPetrik
Copy link
Contributor Author

@jozef-budac testing instructions in the issue ticket #2879

@jozefbudac
Copy link

Verified on builded APK on Android OS

@PeterPetrik PeterPetrik merged commit 2772125 into master Oct 30, 2023
8 checks passed
@PeterPetrik PeterPetrik deleted the fix2879_photo_crash branch October 30, 2023 07:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
data corruption - sync failure - crash - anr The most critical classification ready-for-testing Ready to be tested by testers crew - passed review by devs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Crash when switching between projects with photo attachments
4 participants