c++ - QProcess: Destroyed while process is still running -
i using qt developing custom command interface xmgrace, 2d plotting library. have 3 components in project:
a gui made in qt a qthread runs shared object code c in background thread. an xmgrace window connected both above using pipe. (using grace_np library)communication (1) --> (2)
done changing status of global variables declared in shared object code.
communication (1) --> (3)
& (2) --> (3)
using built in functions provided grace_np library.
now, communication (2) --> (1)
causing problems. tried 2 possible ways think of: a) declaring shared object in qt code emits qt signal , called within c code. b) returning thread , using homecoming value perform operation , restart thread.
both these methodologies have given unreliable results. gui gets stuck/causes segmentation fault , message:
qprocess: destroyed while process still running
i not using qprocess class anywhere in code. has become mystery. please provide info on possible causes this.
ps: pipe (3)
1 way , required way only.
edit 1:
fyi i'm using qt 4.2, can't utilize qobject approach , utilize movetothread() i'm sorry not putting code, can't due company policies , because don't know set (its huge). shared c code 400k+ lines
i believe have found culprit problem. seems using class qmessagebox causing problem. using static function of qmessagebox. have tried declaring on both stack , heap, problem still persists. have found removing calls qmessagebox code solves problem. problem is, how show messages? speculating here, possible modal nature of qmessagebox blocking pipe existing between programme , xmgrace , subsequently causing quit? creating custom qmessagebox (non modal) might solve issue.
edit 2:
i'm not calling qmessagebox worker thread. plus way i'm using worker thread, never returns unless close program. give thought qthread::run function of form:
qthread_object::run() { c_init(); c_main(); }
where c_init & c_run functions linked shared c code. impossible phone call qmessagebox within these directly. i'm planning on doing away qmessagebox , using qmainwindow status bar instead. doesn't give entire functionality. suppose bug in qt 4.2
edit 3:
i mentioned before communication (2) --> (1)
causing problems. have done away communication , have discovered more exactly problem caused invoking qmessagebox anytime after starting worker thread. before communication mentioned above causing qt emit signal indirectly , invoke qmessagebox believe culprit.
edit 4:
ok, forgot mention biggest mystery surrounding problem since beginning. work(place a) via ssh on workstation(place b) on code , run program. b connected on 2 physical networks. connected b through network 1. problem has never occured while working terminal @ (ie on ssh via network 1). consistently occurs when access b straight or through ssh on network 2. please note every time code executed on b only. both these networks used hundereds.
edit 5
finally, have solved problem sub-classing qdialog , making custom messagebox don't require extended functionality of qmessagebox. still don't know exactly within qmessagebox causing problem. suppose bug within qt remain mystery.
since there's no code i'm shooting in dark little here, sounds qprocess created on stack, intentionally or not, or qthread getting destroyed prematurely. i'd set money on qthread objects beingness launched incorrectly. it's hard blame since documentation (or until recently) screwy. consider reading this thread , this thread , don't sub-class qthread @ all.
edit: if qmessagebox culprit, i'm guessing you're displaying kid thread. documentation:
in gui applications, main thread called gui thread because it's thread allowed perform gui-related operations.
there several ways display messages kid thread. personally, utilize qt's error reporting scheme , redirect qcritical, qdebug, etc stderr
. easier way emit
qstring signal worker thread that's caught gui thread, displays/collects error. have mainwindow collect errors , display them @ 1 time when worker thread finishes.
edit 2: since problem seems qmessagebox beingness modal (i.e., blocking main thread while worker thread moves forward), can solve using qmessagebox in non-modal modes. pass 0
parent widget in qmessagebox constructor/static function. processing go on without waiting user exit window--this might result in multiple message boxes beingness open @ same time. if helps avoid error, go on code create sure windows destroyed after closing.
c++ c multithreading qt4 multiprocess
No comments:
Post a Comment