There is a big project consisting of several components, presented in the form of dll. In one component I use QLibrary, for a call of a code from. Previously, everything worked well, the dll was loaded and everything worked correctly, however, after making a change to the dll code and recompiling it, on one of the launches, when I call the load method, the program just hangs.
I tried to clean the entire project and rebuild it from scratch, but when I call the boot method, the execution constantly stops. It does not give any errors. isLibrary, called before the load, confirms that the library is selected correctly.
void libLoad( QLibrary &lib, const QString &fileName ) {
lib.setFileName( fileName + dllVersionString );
auto name = lib.fileName( ); //just to make sure the name is correct
auto isLibrary = lib.isLibrary( fileName + dllVersionString ); //just to make sure dll is found
if ((lib).load( )) { //work stops here
qDebug( ) << QString( "library " + lib.fileName( ) + " loaded" );
} else {
throw QString( QString::fromLocal8Bit( "Failed to load library " ) + lib.fileName( ));
}
}
The problem arises only with debug. I use Qt Creator, with msvc.
The problem was at the breakpoints. I did not understand how they affected the work of the project, but after eliminating all breakpoints and restructuring the component from scratch, the problem went away.
I would be grateful if someone explains the reason for this behavior.
Related
I am using QProcess::start to launch Qt Assistant with my custom help project file. It works fine until i load project(not help project file) to my programm. Programm generates images from specific data using custom library. Even when all processes ends and i see generated images and nothing else happens, when i trying to launch Qt Assistant, my programm hangs at QProcess:start function when trying to start process. The code is:
show() function(public):
if (!run())
return false;
QByteArray ba("setSource ");
ba.append("qthelp://insyn_help/doc/");
proc->write(ba + page.toLocal8Bit() + '\n');
return true;
run() function(private):
if (!proc)
proc = new QProcess();
if (proc->state() == QProcess::Running)
return true;
QString app = QString(QT_BIN_DIR) + QDir::separator() + QString("assistant");
QString path = QString(PREFIX) + QString(HELP_INSTALL_PATH) + QString("/help_project.qhc");
QStringList args;
args << QLatin1String("-collectionFile")
<< QLatin1String(path.toLatin1())
<< QLatin1String("-enableRemoteControl");
QFileInfo help_project(path);
if (help_project.exists()) {
proc->start(app,args);
if (!proc->waitForStarted()) {
m_exitCode = 1;
emit closed();
return false;
}
}
This code is a part of AssistantLauncher class which was registered using qmlRegisterType and added to main.qml as a member of application window. My programm doesn't touch it anywhere (except calling a method show()). It is separate object (except it is a part of appWindow). The question is why does the process can not start only after my programm did some work? And why QProcess::start even dont have timeout.
UPD: I moved proc->start(app,args); to the child process, which i getting by using fork() and now my programm hangs on pid_t child = fork(). So the problem is that new process can not be created.
The answer is to do not use fork() because it is dangerous in big projects. More at http://www.evanjones.ca/fork-is-dangerous.html . posix_spawn also hangs my project. Now i decided to fork() new process at the beginning and send commands to it through the pipe.
I have issue using OpenCV 3 tracking module for tracking. It behaves same, either I use interface class (cv::Tracker) or class with implementation (like cv::TrackerMedianFlow or cv::TrackerMIL, etc). Sample is a bit modified sample from OpenCV sample folder
After correct creation
Ptr<Tracker> tracker = Tracker::create( tracker_algorithm );
if ( tracker == NULL )
{
std::cout << "***Error in the instantiation of the tracker...***\n";
return -1;
}
initialization works just fine
if ( !tracker->init( frame, boundingBox ) )
{
std::cout << "***Could not initialize tracker...***\n";
return -1;
}
Problem occurs late on, withing main loop, when tracking is lost. I use separate detector for defining new target. When I find new target, I clear tracker and initialize it with new value
tracker->clear( );
if ( !tracker->init( frame, detectedNewBBox) )
{
std::cout << "***Could not initialize tracker without history...***\n";
return -1;
}
However, initialization always returns false. I am trying to find out WHY tracker cannot be initialized?
Data was check few time, and looks pretty correct. I even conducted small experiment, trying to initialize tracker right after creation with same data it won't initialize withing loop and it works perfect.
Am I doing something wrong? I was unable to find any documentation on this...
Here is link to available documentation on this:
OpenCV 3 Tracker documentation
Thanks for any effort!
I just ran into the same problem, here's how I got it to work :
tracker->clear();
Ptr<Tracker> trackerNew = Tracker::create( tracker_algorithm );
tracker = trackerNew;
tracker->init( image, boundingBox );
Might not be the right way or the prettiest but it does the job :)
If you want to track a new ROI (region of interest) then I suggest that you should create a new tracker instead of clearing and trying to reuse a previous tracker. Re-use when you need to call init will provide no extra benefit. As you have observed, re-initializing a tracker is not allowed by default.
But if you want to resume tracking of the same object with your correction, it might be possible by doing following steps (I have not tried it myself yet. following code is just a pseudo code)
Ptr<TrackerModel> model = tracker->getModel();
Ptr<TrackerTargetState> lastTargetstate = getLastTargetState();
// Make changes to lastTargetState (update position etc)
// Set lastTargetState, I am not sure if you need to actually set it
// or just editing the object through pointer should work.
model->setLastTargetState(lastTargetstate);
I ran into the same problem and here's my solution:
Open the file in opencv_contrib/modules/tracking/src/tracker.cpp and apply the following changes:
- if( isInit )
+ /*if( isInit )
{
return false;
}
+ */
I recompiled opencv3 and reinstalled it. That fixed it for me. I think they did not want people to reinitialize the tracker for some reason. I am not sure why?
I successfully managed to compile Qt 4 including WebKit for WinCE. QWebView seems to run fine - I can load a HTML5 document and it gets displayed.
ui.webView->page()->settings()->setAttribute(QWebSettings::JavascriptEnabled, true);
ui.webView->setUrl(QUrl::fromLocalFile(QFileInfo(QLatin1String("test.html")).absoluteFilePath()));
However, as soon as the page contains any JavaScript (even an empty script-tag already causes the problem), QWebView will only display a blank page.
The QWebInspector window can also not be shown, as it also just displays a blank window.
I doubt this is a common problem, so my question is, how I could dig into that issue. Is there any debug log for QWebView?
Unfortunately, there's no exception or assertion failure being thrown while execution.
Any ideas? :)
Thank you in advance.
EDIT:
Here is the test code creating the problem. The first four lines of loadFinished are some test code to check valid pointers and whether I could call methods on QWebFrame at all. All code lines execute well until the evaluateJavaScript, where I get an access violation.
I could not post the HTML code inside setHtml, seems to be forbidden by Stackoverflow.
ce0::ce0(QWidget *parent, Qt::WFlags flags)
: QMainWindow(parent, flags)
{
ui.setupUi(this);
connect(ui.webView, SIGNAL(loadFinished(bool)), SLOT(loadFinished(bool)));
ui.webView->page()->settings()->setAttribute(QWebSettings::LocalContentCanAccessRemoteUrls, true);
ui.webView->page()->settings()->setAttribute(QWebSettings::LocalContentCanAccessFileUrls, true);
ui.webView->page()->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
ui.webView->page()->settings()->setAttribute(QWebSettings::JavascriptEnabled, true);
//ui.webView->setUrl(QUrl::fromLocalFile(QFileInfo(QLatin1String("test.html")).absoluteFilePath()));
ui.webView->setHtml(...);
}
void ce0::loadFinished(bool ok) {
QWebPage* p = ui.webView->page();
QWebFrame* f = p->mainFrame();
QString qs = f->title();
bool x = ui.webView->page()->settings()->testAttribute( QWebSettings::JavascriptEnabled );
f->evaluateJavaScript("document.getElementById(\"content\").innerHTML = \"Whatever\";");
}
I'm getting the following error when trying to use the Direct Show 9 backend with qt's phonon framework:
Pins cannot connect due to not supporting the same transport. (0x80040266)
Does anyone know what this error means and/or how to fix it? Is this a problem with the Direct Show 9 backend for phonon?
Apparently the problem has to do with bad metadata. If the Id3 tags aren't just right, the direct show 9 backend chokes on them. I solved the problem by writing the following function:
void removeTags(UDJ::DataStore::song_info_t& song){
static int fileCount =0;
if(song.source.fileName().endsWith(".mp3")){
UDJ::Logger::instance()->log("On windows and got mp3, copying and striping metadata tags");
QString tempCopy = QDesktopServices::storageLocation(QDesktopServices::TempLocation) + "/striped" + QString::number(fileCount) +".mp3";
if(QFile::exists(tempCopy)){
UDJ::Logger::instance()->log("Prevoius file existed, deleting now");
if(QFile::remove(tempCopy)){
UDJ::Logger::instance()->log("File removal worked");
}
}
bool fileCopyWorked = QFile::copy(song.source.fileName(), tempCopy);
if(!fileCopyWorked){
UDJ::Logger::instance()->log("File copy didn't work");
return;
}
TagLib::MPEG::File file(tempCopy.toStdString().c_str());
file.strip();
file.save();
Phonon::MediaSource newSource(tempCopy);
song.source = newSource;
if(fileCount == 3){
fileCount =0;
}
else{
fileCount++;
}
}
}
song_info_t is just a struct with a Phonon::MediaSource member in it called source. The function works by using taglib to strip off all of the metadata for a song and save the new song as a temporary file. The function also rotates the filename is uses for the temporary file so that it doesn't create an infinite number of temporary copy files. I hope this helps anyone else who is having this error.
Whenever I debug my AIR app it keeps suspending at a certain line of code...it doesn't give me a reason why, it just says Main Thread (Suspended) No error, no breakpoint at this location either. If I comment out the code so that, that line does not execute, it just does the same thing on a different line of code.
I have no clue why.... What should I do?
Thanks!!
Here is the function it happens in:
public function update (): void
{
dispatchEvent ( new Event ( EVENT_UPDATE_DOWNLOAD_STARTED ) );
var request: URLRequest = new URLRequest ( _newVersionUrl );
urlStream = new URLStream();
updateFileData = new ByteArray();
urlStream.addEventListener ( Event.COMPLETE, streamDownloadComplete );
urlStream.addEventListener ( ProgressEvent.PROGRESS, streamDownloadProgress );
urlStream.addEventListener ( IOErrorEvent.IO_ERROR, versionCheckIOErrorHandler );
urlStream.load(request);
}
this is the line it suspends on:
updateFileData = new ByteArray();
updateFileData is defined outside the function like so:
protected var updateFileData: ByteArray;
I should mention...this code is the code that Updates the version of air..could this be suspending because its trying to update while in adl.exe?
Thanks
Are you using FlexBuilder?
If you are, have you made sure there isn't a breakpoint set somewhere in your SDK source (I sometimes do this by mistake)?
Try checking, via the Debugging profile (Window > Perspective > Flex Debugging), the the Breakpoints view to see whether there's anything in there you don't recognize.
Also, when you're hung up, try stepping through the code (e.g., using F5 or F6) to see if that helps you figure out where the debugger's stopped.
Not 100% sure, because you're not hitting the error but - This might be an issue caused because the docs say you can't do the update while in the debugger:
When testing an application using the
AIR Debug Launcher (ADL) application,
attempting to update the application
results in an IllegalOperationError
exception.
This is from the livedocs.