Skip to content

'Identify' function in a 'QgsMapToolIdentify' descendant crashes #61372

Description

@stoffy28

What is the bug or the crash?

Error is : Debug assertion failed
Expression : _CtrlsValidHeapPointer(block)

IMPORTANT : don't crash if I compile in release mode, crashes in debug mode.

'Identify' function systematically crashes.

Steps to reproduce the issue

Compile and run the code in DEBUG mode.
Then :

  • add a shape layer on the canvas ;
  • activate an instance of MyIdentifyMapTool as the current map tool ;
  • click anywhere on the shape layer ;

Identify function crashes.

MyIdentifyMapTool.h :

#pragma once

#include "qgsmapcanvas.h"
#include "qgssettings.h"
#include "qgsmaptoolidentify.h"
#include "QgsMapMouseEvent.h"

class MyIdentifyMapTool : public QgsMapToolIdentify
{

	Q_OBJECT

private:
	void canvasReleaseEvent(QgsMapMouseEvent* e) override;

public:
	MyIdentifyMapTool(QgsMapCanvas* canvas);

	~MyIdentifyMapTool();

};

MyIdentifyMapTool.cpp :

#include "MyIdentifyMapTool.h"

MyIdentifyMapTool::MyIdentifyMapTool(QgsMapCanvas* mapCanvas) : QgsMapToolIdentify(mapCanvas) {
}

void MyIdentifyMapTool::canvasReleaseEvent(QgsMapMouseEvent* e)
{
    const QgsPointXY point = e->snapPoint();

    QgsMapCanvas* canvas = this->canvas();

    if (e->button() == Qt::LeftButton) {
        QList<IdentifyResult> resultats = identify(e->x(), e->y(), QgsMapToolIdentify::TopDownAll, canvas->layers(), QgsMapToolIdentify::VectorLayer);
    }
}

Versions

C++ API from QGIS 3.40 LTR

Supported QGIS version

  • I'm running a supported QGIS version according to the roadmap.

New profile

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugEither a bug report, or a bug fix. Let's hope for the latter!Crash/Data Corruption

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions