I'm having this error in my Qt Application:
Debug Error!
Program: C:\Qt\Qt5.1.1\5.1.1\msvc2012_64\bin\QtCored.dll
Module: 5.1.1 File: global\qglobal.cpp
Line: 2014
ASSERT: "allArguments.size() == origArgc" in file
kernel\qcoreapplication.cpp, line 2095
#include <QCoreApplication>
#include <QDebug>
#include <QStringList>
int main(int argc, char *argv[])
{
QCoreApplication app(argc,argv);
qDebug()<<"argc:" << argc;
qDebug()<<"arguments:"<<app.arguments().length();
return 0;
}
Why is that so?
The issue was that I was passing arguments with a new line character in it.
After I removed, it worked again.
Related
I have one csv file in which 3 column and 866300 lines. I have try to write this data into other csv file. when i try to write it has write 866248 lines in file after that remaining 52 lines are not write in file. what is the problem I do not understand it. I have try to debug this problem using print that data on console then it has print till last line on the console. only the problem in write the data in file.
#include <QCoreApplication>
#include <QFile>
#include <QStringList>
#include <QDebug>
#include <QTextStream>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QFile file("C:/Users/hello/Downloads/hello.csv");
QFile write("new_data.csv");
if(!file.open(QIODevice::ReadOnly | QIODevice::Text))
{
qDebug()<<file.errorString();
return 1;
}
if(!write.open(QIODevice::WriteOnly |QIODevice::Append))
{
qDebug()<<file.errorString();
return 1;
}
QTextStream out(&write);
QStringList data;
while (!file.atEnd())
{
QString line = file.readLine();
data = line.split(',');
if (data[0]=="v1")
{
out<<line;
continue;
}
else
{
int seq = (data[0].toInt())-1;
QString str = QString::number(seq)+","+data[1]+","+data[2].trimmed();
qDebug()<<str;
out<<str<<"\n";
}
}
return a.exec();
}
please help.
Please close the file before the return a.exec(); this line and after the while loop. add this line below line.
write.close();
I looked up to documantation and found a very convenient AVInputFormat's funciton get_device_list . But the problem is I can't use it.
Here's my short code snippet
#include <QDebug>
extern "C"
{
#include <libavformat/avformat.h>
#include <libavdevice/avdevice.h>
}
int main(int argc, char *argv[])
{
avdevice_register_all();
AVFormatContext *formatContext = avformat_alloc_context();
AVInputFormat *inputFormat = av_find_input_format("dshow");
AVDeviceInfoList devices;
inputFormat->get_device_list(formatContext, &devices);
qDebug() << devices.nb_devices;
avformat_free_context(formatContext);
return 0;
}
And that code CRASHES when I'm trying to print devices. How do I use that function properly? The official domentation has no examples using that function.
I am trying to run a test in the main function, but the error "you cannot overload the main () function"is displayed.
#define CATCH_CONFIG_RUNNER // -- main() создавать нужно --
#include "catch.hpp"
int main(int argc, char* argv[])
{
setlocale(LC_ALL, "Russian");
int result = Catch::Session().run(argc, argv);
system("pause");
return result;
}
You should use Catch in some other way. Something like that worked for me:
#include <iostream> // some standard includes, whatever you need
#define CATCH_CONFIG_MAIN
#include "catch.hpp"
TEST_CASE("My first test") {
// --- test code here ---
}
TEST_CASE("My second test") {
// --- test code here ---
}
Try the framework's tutorial to learn more =)
I have a project named Movies and I run some tests from googletest on it. I included the whole project and started running tests:
#include "gtest/gtest.h"
#include "Counter.h"
#include <iostream>
using namespace std;
TEST(CodeTest, failTest)
{
Counter c;
EXPECT_EQ( 7, c.getValue() );
}
TEST(CodeTest, plusEqualsConstructor)
{
Counter f,g;
f=g+1;
EXPECT_FALSE(f==g);
}
and my main program is:
#include "gtest/gtest.h"
using namespace std;
int main(int argc, char** argv)
{
testing::InitGoogleTest(&argc, argv);
RUN_ALL_TESTS();
return 0;
};
at first it worked as expected and then it gave me the following weird error:
make:*** [unit_test] Error 1
does anyone know what the problem can be? Thank you !!
Code bellow. In this variants it doesn't work, it says:
int main(int, char**): mount error msg `Method "FilesystemMount" with signature "bas" on interface "org.freedesktop.UDisks.Device" doesn't exit.
But if I replace "#if 0" with "#if 1" all will works fine.
Can you explain?
#include <cstdio>
#include <cstdlib>
#include <QtCore/QCoreApplication>
#include <QtCore/QStringList>
#include <QtDBus/QDBusMessage>
#include <QtDBus/QDBusPendingReply>
#include <QtDBus/QDBusConnection>
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
if (argc != 2) {
fprintf(stderr, "Usage: %s path/to/device\n", argv[0]);
return EXIT_FAILURE;
}
const QString dev_path(argv[1]);
auto mount_call = QDBusMessage::createMethodCall("org.freedesktop.UDisks", dev_path, "org.freedesktop.UDisks.Device", "FilesystemMount");
#if 0
QList<QVariant> args;//WHY THIS WORKS???
args << QVariant(QString()) << QVariant(QStringList("sync"));
#else
QList<QVariant> args;//AND WHY THIS NOT WORKS???
QVariant filesystem_type(QString());
QVariant opts(QStringList("sync"));
args << filesystem_type << opts;
#endif
mount_call.setArguments(args);
QDBusPendingReply<QVariantMap> mount_res = QDBusConnection::systemBus().call(mount_call);
if (!mount_res.isValid())
fprintf(stderr, "%s: mount error msg `%s'\n", __PRETTY_FUNCTION__, mount_res.error().message().toLocal8Bit().data());
return app.exec();
}
So for me this looks likes:
Container<T> c;
T a;
T b;
c.append(a);
c.append(b);
vs
Container c;
c.append(T());
c.append(T());
but the content of "c" should be the same after end of both control flow?
Ok, I found the reason:
compiler thought that:
QVariant filesystem_type(QString());
is a pointer to function, not a QVariant object;