PDA

View Full Version : Memory leak? sysfer.dll access violation exception



froeben
18th February 2016, 07:09
Hello,

i have written a qml-map widget which gets displayed, but there seems to be an "undefined" object or something like that. I get an access violation exception from sysfer.dll.

I currently don't know where this comes from. Any help would be appreciated!

main.cpp


#include <QtWidgets/QApplication>
#include <MainWindow.h>

int main(int argc, char *argv[])
{
QApplication a(argc, argv);
// load resources from binary
// infos: http://doc.qt.io/qt-5/resources.html
Q_INIT_RESOURCE(qmlsources);

MainWindow mw;
mw.show();

return a.exec();
}


MainWindow.h:


#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QtWidgets/QWidget>
#include <QtWidgets/QMainWindow>
#include <QtWidgets/QPushButton>
#include <QtWidgets/QMenu>
#include <QtWidgets/QMenuBar>
#include <QtWidgets/QLabel>

class MainWindow : public QMainWindow
{
Q_OBJECT

public:
MainWindow();
~MainWindow();

protected:
void contextMenuEvent(QContextMenuEvent *event) Q_DECL_OVERRIDE;

private slots:
void quit();

private:
QPushButton *_quit;
QMenu *_fileMenu;

QLabel *_infoLabel;
QAction *_quitAct;

void createMenus();
void createActions();


};

#endif // MAINWINDOW_H


MainWindow.cpp:


#include <QDir>

#include <QtWidgets/QWidget>
#include <QtWidgets/QPushButton>
#include <QtWidgets/QMenu>
#include <QtWidgets/QMenuBar>
#include <QtWidgets/QLabel>
#include <QtWidgets/QBoxLayout>
#include <QtGui/QContextMenuEvent>

#include <QQmlEngine>
#include <QQmlComponent>
#include <QQuickView>
#include <QQuickWidget>
#include "MainWindow.h"

MainWindow::MainWindow() : QMainWindow ()
{
// embed resources into binary
// infos: http://doc.qt.io/qt-5/resources.html
Q_INIT_RESOURCE(qmlsources);

this->resize(1024, 768);

createActions();
createMenus();

//WORKS!!!
QQmlEngine *engine = new QQmlEngine(this);
QQuickWidget *view = new QQuickWidget(engine, this);
view->setSource(QUrl("qrc:/map.qml"));

this->setCentralWidget(view);
view->setResizeMode(QQuickWidget::SizeRootObjectToView);
}

MainWindow::~MainWindow()
{

}

void MainWindow::contextMenuEvent(QContextMenuEvent *event)
{
QMenu menu(this);
menu.addAction(_quitAct);
menu.exec(event->globalPos());
}

void MainWindow::createMenus()
{
_fileMenu = menuBar()->addMenu(tr("File"));
_fileMenu -> addAction(_quitAct);

}

void MainWindow::createActions()
{
_quitAct = new QAction(tr("Quit"), this);
connect(_quitAct, &QAction::triggered, this, &MainWindow::quit);

}

void MainWindow::quit()
{
// _infoLabel->setText(tr("Invoked <b>File|Quit</b>"));
exit(1);
}


map.qml:


import QtQuick 2.3
import QtPositioning 5.6
import QtLocation 5.6

Map {
id: map
width: 640
height:480

plugin: Plugin {
name: "osm"
}

center {
latitude: -27
longitude: 153
}
zoomLevel: 10
gesture.enabled: true

Component.onCompleted: {
console.log("Dimensions: ", width, height)
}
}


Using VisualStudio2015 Ultimate, compiling as debug mode!

Thanks in advance for any hint or comment!

ChrisW67
19th February 2016, 20:49
I currently don't know where this comes from. Any help would be appreciated!

You are ahead of us... We don't even know what the error message was.

Run the program in your debugger and get a stack backtrace when it crashes. Read down the trace until you find the first line of your code that is mentioned.

froeben
22nd February 2016, 10:51
Debugging is not possible since i don't have pdb files for sysfer.dll.

ChrisW67
22nd February 2016, 20:19
Sysfer.dll is not your code, so the absence of the ability to debug it is largely irrelevant. Read down the backtrace until you reach the first line of your code that is mentioned. This is the trigggering event and the place to start working out what your code has done. In all likelihood you are trying to use a null, uninitialised, or invalid pointer.

froeben
29th February 2016, 16:47
I have found out, that the access violation happens when i use the scroll-wheel of my mouse.
I assume, that i need to re-implement the mouse events, because the scroll-functionality may lead to not getting new data within the OSM interface.

My stack trace only tells me, that the error happens in the external dll.
But right after using the scroll-wheel.

Any hint would be appreciated.