openDDS not generating typesupportc header - idl

Im running into an issue with getting TAO_idl not generating typesupportc header. the dds_TAOv2_all.sln builds just fine and all the examples generate their respectful typesupport files including the typesupportc.h file that is necessary for the typesupport_var in my IDL file.
module X {
#pragma DCPS_DATA_TYPE "X::packet"
#pragma DCPS_DATA_KEY "X::packet from"
typedef sequence<octet> binary;
struct packet {
string from;
long packet_id;
long count;
long timer;
binary mydata;
};
};
the Xtypesupportc.h was genereated before, but ever since I had to reload DDS(DDS is compiled configured etc) when I run tao_idl and openDDS_idl with the x.idl file the xtypesupportc and xtypesupports don't get created and thus I can't register the type. any obvious thing that I am doing wrong? thank you.

Related

QSoundEffect does not reload source

In my program it is possible to select a sound for an action. the sound is changeable, which means the .wav file gets replaced by another file.
This may cause the problem. When i replace the file and set the source of the QSoundEffect the sound does not change.
At the moment i am having a source like this:
//variable in .h
QUrl sound = "file:///"+soundDirectory+"sound.wav";
QUrl newSound = "file:///"+soundDirectory+"newSound.wav"; ;
QSoundEffect soundeffect;
//called in setSound() in .cpp
soundEffect.setSource(sound);
the sound loads without problem and i can play that sound.
i can change that sound with this code
// changing the sound in changeSound()
soundEffect.setSource(newSound);
this also works fine. the new sound is loaded and i can play it.
But it is also possible to change the sound files in the directory:
//changeSoundFile()
QFile::remove(sound.toLocalFile());
QFile::copy(anyPossibleSound.toLocalFile(), sound.toLocalFile());
This also works and replaces the sound file in its directory with another.
If I call setSound() after changing the file. It seems like the file does not get reload. and the sound is not changed. This is also the problem if changed the sound in between (call setSound on startup, then changeSound, then changeSoundFile and the setSound again)
Am I overlooking something?
It's not mentioned in the official docs, but you can find the implementation on GitHub:
void QSoundEffect::setSource(const QUrl &url) {
if (d->source() == url)
return;
d->setSource(url);
emit sourceChanged();
}
The file does not get reloaded because the URL is the same. The implementation holds an internal cache with the data that has been loaded before, so when you play the file, nothing change.
The API does not provide a way of forcing the reset of the data source. You have two alternatives:
Re-creating the QSoundEffect instance each time you modify the file.
Changing the file name:
// Create a temporal file
const auto uuid = QUuid::createUuid();
const auto new_filename = uuid.toString() + ".wav";
// Copy the file
QFile::remove(sound.toLocalFile());
QFile::copy(anyPossibleSound.toLocalFile(), new_filename);
sound = QUrl(new_filename);
// Use it
soundEffect.setSource(sound);

Qt5: download a file without saving to HDD

I'm trying to download a file in Qt5, but the file must not be located on the HDD after download.
To clarify> My app will use a downloaded file to update some firmware, and I don't want the downloaded update to remain on the user's hard drive because it could get stolen.
So, I'm trying to make a QFile from QNetworkReply* but without saving it to some path on a hard drive.
I'm downloading a file using QNetworkAccessManager and storing the data into QNetworkReply. I always used to make a QFile with QNetworkReply*, but now I can't do that.
I have found the QTemporaryFile class where a file gets removed right after using it, but that still leaves user with some options of finding the file later.
I tried typecasting that QNetworkReply* as a QFile, but didn't manage to get that to work, seems like QFile can't be without a path on HDD.
Does anyone have any ideas how to do this, and how?
Thanks everyone.
Again not sure your intended end use case but since your data is small enough to hold in memory you can use a QByteArray or QBuffer and write into it from your QNetworkReply. QBuffer provides a QIODevice interface for the QByteArray so it may be a bit easier for you to work with.
Make sure to open the QBuffer for read/write. See the simple example below from the Qt documentation, http://doc.qt.io/qt-5/qbuffer.html#details, below:
QBuffer buffer;
char ch;
buffer.open(QBuffer::ReadWrite);
buffer.write("Qt rocks!");
buffer.seek(0);
buffer.getChar(&ch); // ch == 'Q'
buffer.getChar(&ch); // ch == 't'
buffer.getChar(&ch); // ch == ' '
buffer.getChar(&ch); // ch == 'r'
That should allow you to read back the data and use as required without creating a file on the system.

QObject::tr() not translating language properly

QLocale systemLocale;
LOG_ERROR() << "SYSTEM LANGUAGE:" << systemLocale.languageToString(systemLocale.language());
LOG_ERROR() << QObject::tr("Welcome");
The second line prints the correct language, when I change the language from the phone settings, however, "Welcome" doesn't get translated to the current system language. What could be the issue with this?
The translation is probably not loaded. Here's how you can load a file:
QTranslator translator;
QString locale_string = QLocale().name();
QString filename = QString("my_app_%1").arg(locale_string);
if (translator.load(filename, "app/native/qm")) {
app.installTranslator(&translator);
}
This would try to load translations from app/native/qm/my_app_fr.qm on a french device, for example.
Note that by default, you'll have to restart the application after changing the device language. You can use a LocaleHandler to update the translation when the phone language changes. Listen to onSystemLanguageChanged() signal, remove the old translator, then load the new one (same code as above).

loading qm file using QTranslator

I'm trying to use translation files. I went through all the procedures:
created ts file, translated it, but when I run the application, the language is still the same as before.
I worked on the Nokia example, just like in the instructions.
What could be my problem?
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QTranslator* translator=new QTranslator(0);
if(QFile::exists("hellotr_la.qm"))
qWarning("failed-no file");
if(! translator->load("hellotr_la.qm"))
qWarning("failed loading"); //the warning appears ****
app.installTranslator(translator);
}
Where are the .qm files located? Your code is attempting to load the file from the current working directory, which can be anything during runtime. Specify a directory path in the call to QTranslator::load:
QTranslator* translator = new QTranslator();
if (translator->load("hellotr_la", "/path/to/folder/with/qm/files")) {
app.installTranslator(translator);
}
Translations can be loaded from Qt resources, so it is a good idea to bundle them inside your executables. Then you would load them somewhat like this:
QTranslator* translator = new QTranslator();
if (translator->load("hellotr_la", ":/resources/translations")) {
app.installTranslator(translator);
}
The answer was already given in a comment, but I want to point it out clearly.
The first warning uses a wrong condition:
if(QFile::exists("hellotr_la.qm"))
qWarning("failed-no file");
It should be:
if(!QFile::exists("hellotr_la.qm"))
qWarning("failed-no file");
Since you only saw the second warning, but not the first one, the problem is indeed that the file was not found. Make sure that the working directory is what you expect it to be or (better) use the resource system as explained by andref.
Based on the example, can you simply try this :
QTranslator translator;
translator.load("hellotr_la");
app.installTranslator(&translator);
Hope it will fix your problem !
Note 1 : No pointer here.
Note 2 : No extension in your filename.

Console Application

Edit:
I don't know what this user originally wanted, and hopefully they'll edit their question to let us know, but otherwise, let's use this question to answer (or give links to) the following common console window issues:
How do you capture the output of a console application in your program (for instance, running a build process and getting the output in your IDE)?
How do you get your console application to hang around long enough to see the output when you hit "run" in the IDE? (ie, getch for C, some IDEs have options to set, what common/popular pause and wait for keypress routines do you use to keep the console window open long enough to see the output? This applies to lots of languages - list your method)
Original question:
How to view console application output
screen(black screen).Please mention in
detail.
Keeping the console window open in for C++ in a standard's compliant way (not platform specific):
#include <iostream>
#include <limits>
int main() {
// Rest of the code
//Clean the stream and ask for input
std::cin.ignore ( std::numeric_limits<std::streamsize>::max(), '\n' );
std::cin.get();
return 0;
}
Source.
-Adam
Keeping the console window open in C:
/* Example waits for a character input */
#include <stdio.h>
int main()
{
/* Put your code here */
getchar();
return 0;
}
getchar is standards compliant, while getch (a common usage) is platform specific.
-Adam
In c# I just put a break point at the end of my code to keep the console window open. I used to use Console.Read(); but got sick of typing it...
Edit: btw I just use this for my debugging purposes. If it needs to be a feature then Console.Read();
If it's a graphical application that happens to write messages to standard output, open your favorite terminal application and type in the command there. If its output exceeds the output buffer of your terminal, pipe it through 'more' or 'less'.

Resources