Invalid parameter passed to C runtime function.
I have a problem with a application. I’ve created a debug handler with a own debug window. On a system without Qt, only the needed files, the windows works as expected, but if i work on a system installed with qt, the application crashs with the output “Invalid parameter passed to C runtime function.” and with an error box from Microsoft Visual C++ Runtime Library.
I’m not sure what the problem is. The debugwindowdemo is a simple ui class with some debug output. The other files i have posted here.
main.cpp
- #include "debugwindowdemo.h"
- #include "debughandler.h"
- #include <QtGui/QApplication>
- #include <QWidget>
- #include <QtGlobal>
- #include <QTextBrowser>
- int main( int argc, char* argv[] ) {
- qInstallMsgHandler(debugWinMsgHandler);
- DebugWindowDemo *dialog = new DebugWindowDemo;
- dialog->show();
- return app.exec();
- }
debughandler.h
- #ifndef DEBUGHANDLER_H
- #define DEBUGHANDLER_H
- #include "debugwindow.h"
- void debugWinMsgHandler (QtMsgType type, const char* msg) {
- static DebugWindow* debugWindow = new DebugWindow;
- debugWindow->move(0,0);
- debugWindow->show();
- switch(type) {
- case QtDebugMsg:
- break;
- case QtWarningMsg:
- break;
- case QtCriticalMsg:
- break;
- case QtFatalMsg:
- break;
- }
- }
- #endif
debugwindow.h
- #ifndef DEBUGWINDOW_H
- #define DEBUGWINDOW_H
- #include <QDialog>
- namespace Ui {
- class DebugWindow;
- }
- {
- Q_OBJECT
- public:
- ~DebugWindow();
- public slots:
- private:
- Ui::DebugWindow *ui;
- private slots:
- void print();
- void save();
- };
- #endif // DEBUGWINDOW_H
debugwindow.cpp
- #include "debugwindow.h"
- #include "ui_debugwindow.h"
- #include <QMessageBox>
- #include <QFileDialog>
- #include <QTextStream>
- #include <QPrintDialog>
- #include <QPrinter>
- #include <QFont>
- ui(new Ui::DebugWindow)
- {
- this->setFont(newFont);
- ui->setupUi(this);
- ui->tbClear->setVisible(false);
- connect(ui->tbClear,SIGNAL(clicked()),ui->leSearch,SLOT(clear()));
- connect(ui->pbPrint,SIGNAL(clicked()),this,SLOT(print()));
- connect(ui->pbSave,SIGNAL(clicked()),this,SLOT(save()));
- connect(ui->pbClose,SIGNAL(clicked()),this,SLOT(close()));
- }
- DebugWindow::~DebugWindow()
- {
- delete ui;
- }
- {
- ui->teLog->append(str);
- }
- {
- ui->tbClear->setVisible(!pattern.isEmpty());
- QTextCharFormat noBackground;
- noBackground.clearBackground();
- QTextCharFormat highlight;
- allText.setCharFormat(noBackground);
- while (!cursor.isNull()) {
- cursor.setCharFormat(highlight);
- cursor = document->find(expression,cursor,0);
- }
- }
- void DebugWindow::save()
- {
- QString fileName = QFileDialog::getSaveFileName(this,QObject::tr("Logfile speichern"),QDir::homePath(),QObject::tr("Logfile (*.log)"));
- if (!fileName.isEmpty())
- {
- if (!fileName.endsWith("log"))
- {
- fileName = fileName+".log";
- }
- {
- .arg(fileName)
- }
- else
- {
- out.setGenerateByteOrderMark(true);
- out << ui->teLog->toPlainText();
- file.close();
- .arg(fileName)
- }
- }
- }
- void DebugWindow::print()
- {
- QPrinter printer;
- {
- return;
- }
- document->print(&printer);
- }
7 replies
The same version is installed on the system where it crash. the “funny” part is, on a system without qt sdk, only with the needed qt files (libgcc_s_dw2-1.dll, mingwm10.dll, QtCored4.dll, QtGuid4.dll) it works.
Last night i found out (lot of things i’ve tried eg switching debugwindow from qdialog to qwidget), that it has to be a problem of the ui file (i think so)… i created a new designer class, copied!!! the code into the cpp/h files and “copied” the ui elements with the designer to the other ui file… and you wouldn’t believe it, it works.. i will post the original ui file… i haven’t found any errors within, but maybe there is another problem:
debugwindow.ui
http://pastebin.com/XpiyNF3K
Thanks for the hint here Torsten – I had a similar problem here. The only difference was a .qml file was saved with whatever System encoding Mac runs, and on my Win7 I got the same “Invalid parameter passed to C runtime function.” error.
The fix was to “Save with Encoding” UTF-8 and rebuild – then it worked without errors? Did you file a bug-report?
_Update: _ Actually turned out to be another bug (exception thrown and the program didn’t know what to do) :) Nevermind, nothing to see here :D
You must log in to post a reply. Not a member yet? Register here!




