PDA

View Full Version : Qwt Runtime Errors (Windows)



chriskon149
11th November 2011, 02:15
Hey guys,

I've been having an error with a pretty simple Qt and Qwt application that I've written. I keep on getting this error when I try to run it from Qt Creator (in release mode):

Starting C:\Users\Chris\Documents\Robotics2011SVN\TestCanTo pside3\release\TestCanTopside.exe...
Invalid parameter passed to C runtime function.
Invalid parameter passed to C runtime function.
QWidget: Must construct a QApplication before a QPaintDevice
The program has unexpectedly finished.
C:\Users\Chris\Documents\Robotics2011SVN\TestCanTo pside3\release\TestCanTopside.exe exited with code 62097

Other times it exits with Error Code 3.

Also, after it (my application) has crashed, I was able to see the Windows crash file that it created, and it mentioned QtCored4.dll even though I'm building it for release. Also, after running the .exe (release) through Dependency Walker, it said that it had issues finding QtCored4.dll and QtCore4.dll. Why would it look for both? As a side note, I'm running on Win7 64bit and it said that the different .dll's were for different CPUs (x86 vs x64). Could that be my issue?

I compiled Qwt with mingw32 and I also compiled Qt Creator with mingw32 (both as dynamic), and the plugin seems to work fine. My application worked fine this morning, but for no apparent reason things just changed. I can run an .exe that I compiled earlier today just fine, but I can't compile and run any newer .exe's.


What am I doing wrong here and how can I fix it? I've been all over Google and the forums, but I can't figure this out (I'm relatively new to Qt and C++, switched from Arduino programming to Qt in July 2011).

Here's my code:

*.pro


QT += core gui\
network

INCLUDEPATH += C:\Qwt-6.0.1\include
LIBS += C:\Qwt-6.0.1\lib\qwt.dll

#QWT_LOCATION = C:/qwt-6.0.1-source
#INCLUDEPATH += $${QWT_LOCATION}/src
#LIBS += -L$${QWT_LOCATION}/lib -lqwt

CONFIG += release

TARGET = TestCanTopside
TEMPLATE = app


SOURCES += main.cpp\
mainwindow.cpp

HEADERS += mainwindow.h

FORMS += mainwindow.ui


*.h

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include "QtNetwork/qhostaddress.h"
#include "QtNetwork/qudpsocket.h"
#include "QtNetwork/qabstractsocket.h"
#include "QNetworkInterface"
#include "QHostAddress"
#include "QtNetwork"
#include "QTextStream"
#include <Qwt/qwt.h>
#include <Qwt/qwt_plot_curve.h>
#include <Qwt/qwt_plot.h>
#include <Qwt/qwt_series_data.h>
#include <QPointF>
#include <Qwt/qwt_plot_marker.h>
#include <Qwt/qwt_abstract_scale_draw.h>
#include <Qwt/qwt_scale_draw.h>
#include <QPainter>
#include <QPalette>
#include <Qwt/qwt_dial.h>
#include <Qwt/qwt_dial_needle.h>
#include <Qwt/qwt_compass.h>
#include <Qwt/qwt_compass_rose.h>

namespace Ui {
class MainWindow;
}

class QUdpSocket;

class MainWindow : public QMainWindow
{
Q_OBJECT

public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();

private slots:
void on_sendButton_clicked();
void findHostIP();
void on_configButton_clicked();
void processPendingDatagrams();
private:
Ui::MainWindow *ui;
QTime *myTime;
QwtPlotCurve *myCurve;
QVector<QPointF> myPoints;
int index;

double depthReadout;
double otherReadout;
double voltsReadout;
double ampsReadout;
double headingReadout;
double tempReadout;
QUdpSocket *udpSocket;
QUdpSocket *rxUdpSocket;
int rxPort;
int listenPort;
QHostAddress txIP;
bool userIP;
QString rxString;
};

#endif // MAINWINDOW_H

*.cpp

#include "mainwindow.h"
#include "ui_mainwindow.h"


MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
udpSocket = new QUdpSocket(this); //create UDP Socket(tx)
rxUdpSocket = new QUdpSocket(this); //create UDP Socket(rx)
rxUdpSocket->bind(12345); //found in book
connect(rxUdpSocket, SIGNAL(readyRead()), this, SLOT(processPendingDatagrams()));
findHostIP();
//Set Tab order for UI
setTabOrder(ui->rxIPLE, ui->portLE);
setTabOrder(ui->portLE, ui->rxPortLE);
setTabOrder(ui->rxPortLE, ui->dsbMaxDepth);
setTabOrder(ui->dsbMaxDepth,ui->configButton);
setTabOrder(ui->configButton, ui->packetLE);
setTabOrder(ui->packetLE, ui->sendButton);

//Setup Qwt Stuff
ui->plotDepth->setAxisAutoScale(2, false); //turn off y axis auto scale
ui->plotDepth->setAxisScale(0,-4.0,0,0.5); //set y axis scale
ui->plotDepth->setAutoReplot(true); //automatically update the plot
ui->plotDepth->setAxisTitle(QwtPlot::xBottom, "Time in Seconds");
ui->plotDepth->setAxisTitle(QwtPlot::yLeft, "Depth in Meters");
ui->plotDepth->setAxisMaxMinor(2, 30); //x axis minor ticks = 30
ui->plotDepth->axisScaleDraw(2)->enableComponent(QwtAbstractScaleDraw::Labels, false);

myTime = new QTime; //QTime for axis
myTime->start();

myCurve = new QwtPlotCurve; //create the curve for the graph
myCurve->setPen(QPen(QColor::QColor(65,105,225,255))); //set the curve color
myCurve->attach(ui->plotDepth); //connect the curve to the graph

index = 0; //the index holds the number of points

//Setup the colors of the compass
QPalette *colorGroup = new QPalette(Qt::lightGray, Qt::white, Qt::white, Qt::white, Qt::white, Qt::white, Qt::white, QColor::QColor(65,105,225,255), Qt::white);

ui->compass->setLineWidth(0);

ui->compass->setScaleComponents( QwtAbstractScaleDraw::Backbone |
QwtAbstractScaleDraw::Ticks | QwtAbstractScaleDraw::Labels );
ui->compass->setScaleTicks(0, 0, 3);

//Create tick marks on the compass
QMap<double, QString> map;
for ( double d = 0.0; d < 360.0; d += 30.0 )
{
QString label;
label.sprintf("%.0f", d);
map.insert(d, label);
}
ui->compass->setLabelMap(map);
ui->compass->setScale(36, 5, 0);

//Setup the needle on the compass
ui->compass->setPalette(*colorGroup);
ui->compass->setNeedle(new QwtDialSimpleNeedle(QwtDialSimpleNeedle::Ray,
true, QColor::QColor(65,105,225,255)));
ui->compass->setOrigin(270.0);
ui->compass->setValue(0.0);
}

MainWindow::~MainWindow()
{
delete ui;
}

void MainWindow::on_sendButton_clicked()
{
QString packet = ui->packetLE->text(); //create packet
QByteArray myDatagram = packet.toUtf8(); //convert to datagram

if(userIP == true)
{
udpSocket->writeDatagram(myDatagram.data(), myDatagram.size(),
txIP, rxPort);
}
else
{
udpSocket->writeDatagram(myDatagram.data(), myDatagram.size(),
QHostAddress::Broadcast, rxPort);
}
}

void MainWindow::on_configButton_clicked()
{
rxPort = ui->portLE->text().toInt(); //set port
listenPort = ui->rxPortLE->text().toInt(); //set port to listen on

rxUdpSocket->close();

rxUdpSocket->bind(listenPort); //found in book


if(ui->rxIPLE->text() != NULL) //if user added IP address
{
QString txStrIp = ui->rxIPLE->text(); //create RX IP string
txIP = txStrIp; //Convert to IP Address
userIP = true;
}
else
{
userIP = false;
}

ui->barDepth->setMaximum(int(ui->dsbMaxDepth->value()*100));
ui->plotDepth->setAxisScale(0,-1.0*ui->dsbMaxDepth->value(),0,0.5); //set y axis scale

}
void MainWindow::findHostIP() //found this code online, modified it to only show IP addresses (local)
{
QStringList items;
ui->listWidget->clear();
foreach(QNetworkInterface interface, QNetworkInterface::allInterfaces())
{
if (interface.flags().testFlag(QNetworkInterface::IsR unning))
foreach (QNetworkAddressEntry entry, interface.addressEntries())
{
if ( interface.hardwareAddress() != "00:00:00:00:00:00" && entry.ip().toString().contains("."))
items << interface.name() + " " + entry.ip().toString();
}
}
ui->listWidget->addItems(items);
}

void MainWindow::processPendingDatagrams()
{
QByteArray rxDatagram;
QString rxString;
do
{
rxDatagram.resize(rxUdpSocket->pendingDatagramSize());
rxUdpSocket->readDatagram(rxDatagram.data(), rxDatagram.size());
}
while(rxUdpSocket->hasPendingDatagrams());
rxString = (tr("\"%1\"").arg(rxDatagram.data())); //turn datagram into string
rxString.remove(QChar('"'), Qt::CaseInsensitive); //remove quotation marks
//ui->rxPacketLabel->setText(tr("\"%1\"").arg(rxDatagram.data()));
ui->rxPacketLabel->setText(rxString);
QTextStream packetStream(&rxString);
packetStream >> depthReadout >> voltsReadout >> ampsReadout >> tempReadout >> headingReadout >> otherReadout;

ui->lcdDepth->display(depthReadout);
ui->barDepth->setValue(depthReadout * 100);
ui->lcdOther->display(otherReadout);
ui->lcdVolts->display(voltsReadout);
ui->lcdAmps->display(ampsReadout);
ui->lcdTemp->display(tempReadout);
ui->leHeading->setText(QString::number(headingReadout));
ui->barHeading->setValue(headingReadout*10);

//Qwt stuff
myPoints.append(QPointF(0,0));
myPoints[index].setX(myTime->elapsed());
myPoints[index].setY(-1.0*depthReadout);
index++;
myCurve->setSamples(myPoints);
myCurve->setRenderHint(QwtPlotItem::RenderAntialiased, true);
ui->plotDepth->setAxisScale(2, myTime->elapsed()-10000, myTime->elapsed(), 60000);

ui->compass->setValue(headingReadout);
}

Qt version 4.7.3
Qwt verson 6.0.1

Thanks for the help! I really appreciate it!

Chris

Added after 17 minutes:

I just thought I would include the contents of the file that Windows creates after the crash (WERF3C5.tmp.appcompat.txt)

<?xml version="1.0" encoding="UTF-16"?>
<DATABASE>
<EXE NAME="TestCanTopside.exe" FILTER="CMI_FILTER_PRIVACY">
<MATCHING_FILE NAME="TestCanTopside.exe" SIZE="120832" CHECKSUM="0x94AE05AA" MODULE_TYPE="WIN32" PE_CHECKSUM="0x23E1F" LINKER_VERSION="0x10000" LINK_DATE="11/11/2011 01:22:11" UPTO_LINK_DATE="11/11/2011 01:22:11" EXE_WRAPPER="0x0" FILE_ID="0000998a8720b1423260a4c557dddb609fdc3e996ea8" PROGRAM_ID="0000da39a3ee5e6b4b0d3255bfef95601890afd80709" />
</EXE>
<EXE NAME="QtCored4.dll" FILTER="CMI_FILTER_THISFILEONLY">
<MATCHING_FILE NAME="QtCored4.dll" SIZE="31662865" CHECKSUM="0x8222D8C9" BIN_FILE_VERSION="4.7.3.0" BIN_PRODUCT_VERSION="4.7.3.0" FILE_DESCRIPTION="C++ application development framework." COMPANY_NAME="Nokia Corporation and/or its subsidiary(-ies)" PRODUCT_NAME="Qt4" FILE_VERSION="4.7.3.0" ORIGINAL_FILENAME="QtCored4.dll" LEGAL_COPYRIGHT="Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)." VERDATEHI="0x0" VERDATELO="0x0" VERFILEOS="0x4" VERFILETYPE="0x2" MODULE_TYPE="WIN32" PE_CHECKSUM="0x1E38A2B" LINKER_VERSION="0x10000" UPTO_BIN_FILE_VERSION="4.7.3.0" UPTO_BIN_PRODUCT_VERSION="4.7.3.0" LINK_DATE="03/30/2011 13:34:37" UPTO_LINK_DATE="03/30/2011 13:34:37" EXPORT_NAME="QtCored4.dll" EXE_WRAPPER="0x0" FILE_ID="0000c52acb9a6b94db7dc42c12e6257c82524f5e9c65" PROGRAM_ID="000377025cd5c5d05c0c34a33351fe5411c50000ffff" />
</EXE>
<EXE NAME="kernel32.dll" FILTER="CMI_FILTER_THISFILEONLY">
<MATCHING_FILE NAME="kernel32.dll" SIZE="1114112" CHECKSUM="0x9725986B" BIN_FILE_VERSION="6.1.7601.17651" BIN_PRODUCT_VERSION="6.1.7601.17651" PRODUCT_VERSION="6.1.7600.16385" FILE_DESCRIPTION="Windows NT BASE API Client DLL" COMPANY_NAME="Microsoft Corporation" PRODUCT_NAME="Microsoft® Windows® Operating System" FILE_VERSION="6.1.7600.16385 (win7_rtm.090713-1255)" ORIGINAL_FILENAME="kernel32" INTERNAL_NAME="kernel32" LEGAL_COPYRIGHT="© Microsoft Corporation. All rights reserved." VERDATEHI="0x0" VERDATELO="0x0" VERFILEOS="0x40004" VERFILETYPE="0x2" MODULE_TYPE="WIN32" PE_CHECKSUM="0x1164FD" LINKER_VERSION="0x60001" UPTO_BIN_FILE_VERSION="6.1.7601.17651" UPTO_BIN_PRODUCT_VERSION="6.1.7601.17651" LINK_DATE="07/16/2011 04:27:04" UPTO_LINK_DATE="07/16/2011 04:27:04" EXPORT_NAME="KERNEL32.dll" VER_LANGUAGE="English (United States) [0x409]" EXE_WRAPPER="0x0" />
</EXE>
</DATABASE>


If you look at line 7, you'll see that QtCored4.dll is mentioned, even though I built this using the "release" settings of Qt Creator.

I'm thinking that is tied to my issue, but I don't know how to fix it.

Thanks!

Chris

chriskon149
11th November 2011, 06:10
I used Windows Task Manager to create a dump file for my compiled .exe, and it also shows that QtCored4.dll, QtGuid4.dll and QtSvgd4.dll are included in the "Modules" section. QtNetwork4.dll is also included, but the debug version is not included, unlike QtCore4.dll and QtGui4.dll, which have both release and debug versions listed. QtSvgd4.dll has only the debug version listed.

Here's a screenshot:

7092

chriskon149
16th November 2011, 02:48
Okay, so I got Qwt working by doing a fresh install of the Qt SDK with Qt version 4.7.4 and Qwt version 6.0.1. I followed mpsoft's tutorial at http://www.qtcentre.org/threads/19304-install-Qwt-Qtcreator?p=207749 to get it working. The plugin still does not work, but I can get around that by promoting QWidgets to use Qwt widgets. My .pro file for debug looks like:


INCLUDEPATH += C:/qwt-6.0.1/src
win32:LIBS += C:/qwt-6.0.1/lib/libqwtd.a
win32:QMAKE_POST_LINK = copy /Y C:\qwt-6.0.1\lib\qwtd.dll $(DESTDIR)
CONFIG +=qwt


My .pro for release looks like:


INCLUDEPATH += C:/qwt-6.0.1/src
win32:LIBS += C:/qwt-6.0.1/lib/libqwt.a
win32:QMAKE_POST_LINK = copy /Y C:\qwt-6.0.1\lib\qwt.dll $(DESTDIR)
CONFIG +=qwt


It works like a charm!

Chris

AlexMalyushytsky
19th November 2011, 02:26
On Windows I would not recommend to mix debug and release modules.
This causes unpredictable behaviour.