Re: [Harbour] QT - Multi-threading - A Limitation
Marcos Can you do some deep testings with QT and hb_threadStart()? I mean run some real-time widgets under MT. I have landed into more troubles than solutions with MT in GTQTC. I want to see if Harbour MT modal is meaningful in QT GUI context or not ? It willbecome the basis for next development stratedy whether we should go for single thread or MT way. Regards Pritpal Bedi -- View this message in context: http://www.nabble.com/QT---Multi-threading---A-Limitation-tp23163007p23175485.html Sent from the Harbour - Dev mailing list archive at Nabble.com. ___ Harbour mailing list Harbour@harbour-project.org http://lists.harbour-project.org/mailman/listinfo/harbour
Re: [Harbour] QT - Multi-threading - A Limitation
Pritpal Bedi escreveu: Marcos Can you do some deep testings with QT and hb_threadStart()? I mean run some real-time widgets under MT. I have landed into more troubles than solutions with MT in GTQTC. I want to see if Harbour MT modal is meaningful in QT GUI context or not ? It willbecome the basis for next development stratedy whether we should go for single thread or MT way. Yes, i can do. I will try windows in MT mode with controls like QLineEdit, QCheckBox, QRadioBox and others. Tell me if you want some especific test. Regards, Marcos Gambeta ___ Harbour mailing list Harbour@harbour-project.org http://lists.harbour-project.org/mailman/listinfo/harbour
Re: [Harbour] QT - Multi-threading - A Limitation
Hello Marcos Gambeta wrote: Yes, i can do. I will try windows in MT mode with controls like QLineEdit, QCheckBox, QRadioBox and others. Thanks. Please do whatever you can summerise in MT mode. I am particularly interested in event management. Tell me if you want some especific test. Try to open new MainWindows()s. The facts will be more clear whether it is possible or not. Regards Pritpal Bedi -- View this message in context: http://www.nabble.com/QT---Multi-threading---A-Limitation-tp23163007p23184792.html Sent from the Harbour - Dev mailing list archive at Nabble.com. ___ Harbour mailing list Harbour@harbour-project.org http://lists.harbour-project.org/mailman/listinfo/harbour
Re: [Harbour] QT - Multi-threading - A Limitation
Pritpal Bedi escreveu: It appears multi-threading support in QT is sadly limited and does not go with all-the-powerful offering in Harbour. These are my first experiments and so I may be wrong. I am trying to execute wvtext.prg with -mt option and executing F10New Window which should be executed in a separate thread. I can see new window opened but then the inkey() loop, and also applctn loop, gets cofused. Yet I do not know what is causing such abnormality, QT or gtqtc.c architect. QT documentation suggests that appln always run in a single event loop. If someone has any clues to this paradigm then please speakup, otherwise, to me it seems to be show stopper. I don´t tested gtqtc yet, but Qt have the class QEventLoop: Detailed Description The QEventLoop class provides a means of entering and leaving an event loop. At any time, you can create a QEventLoop object and call exec() on it to start a local event loop. From within the event loop, calling exit() will force exec() to return. Can each Window in gtqtc have your own event loop ? Regards, Marcos Gambeta ___ Harbour mailing list Harbour@harbour-project.org http://lists.harbour-project.org/mailman/listinfo/harbour
Re: [Harbour] QT - Multi-threading - A Limitation
This sample is from my personal library: #include qt.ch Procedure Main () Local oApplication Local oWindow Local oButton oApplication := QApplication():New() oWindow := QWidget():New() oWindow:Resize(320, 240) oWindow:SetWindowTitle(Testing class QEventLoop) oWindow:Show() oButton := QPushButton():New(oWindow) oButton:SetText(OK) oButton:Resize(80, 30) oButton:Move((320-80)/2, (240-30)/2) oButton:Show() oButton:Connect(clicked(), {|p|NewWindow()}) oApplication:exec() Return Function NewWindow () Local oWindow Local oEventLoop Local oButton Static n := 0 ++n oWindow := QWidget():New() oWindow:Resize(320, 240) oWindow:SetWindowTitle(Window +str(n,2)) oWindow:Show() oEventLoop := QEventLoop():New(oWindow) oButton := QPushButton():New(oWindow) oButton:SetText(OK) oButton:Resize(80, 30) oButton:Move((320-80)/2, (240-30)/2) oButton:Show() oButton:Connect(clicked(), {|p|qt_qwidget_close(oWindow:pointer),MsgInfo(Closing window +qt_qwidget_windowtitle(oWindow:pointer)),oEventLoop:exit(0)}) oEventLoop:exec(0) Return nil Using QEventLoop, i can have 'n' windows, each window with your own event loop. Regards, Marcos Gambeta ___ Harbour mailing list Harbour@harbour-project.org http://lists.harbour-project.org/mailman/listinfo/harbour
Re: [Harbour] QT - Multi-threading - A Limitation
Marcos Thanks for the explanation. I know about this facts but note that this operates on different widgets in the main thread. I am talking about different threads. Try this : #include qt.ch Procedure Main () Local oApplication Local oWindow Local oButton oApplication := QApplication():New() oWindow := QWidget():New() oWindow:Resize(320, 240) oWindow:SetWindowTitle(Testing class QEventLoop) oWindow:Show() oButton := QPushButton():New(oWindow) oButton:SetText(OK) oButton:Resize(80, 30) oButton:Move((320-80)/2, (240-30)/2) oButton:Show() oButton:Connect(clicked(), hb_threadStart( {|p|NewWindow()} ) ) oApplication:exec() Return Function NewWindow () Local oWindow Local oEventLoop Local oButton Static n := 0 ++n oWindow := QWidget():New() oWindow:Resize(320, 240) oWindow:SetWindowTitle(Window +str(n,2)) oWindow:Show() oEventLoop := QEventLoop():New(oWindow) oButton := QPushButton():New(oWindow) oButton:SetText(OK) oButton:Resize(80, 30) oButton:Move((320-80)/2, (240-30)/2) oButton:Show() oButton:Connect(clicked(), {|p|qt_qwidget_close(oWindow:pointer),MsgInfo(Closing window +qt_qwidget_windowtitle(oWindow:pointer)),oEventLoop:exit(0)}) oEventLoop:exec(0) Return nil Remember to compile appln with -mt switch. Regards Pritpal Bedi -- View this message in context: http://www.nabble.com/QT---Multi-threading---A-Limitation-tp23163007p23163740.html Sent from the Harbour - Dev mailing list archive at Nabble.com. ___ Harbour mailing list Harbour@harbour-project.org http://lists.harbour-project.org/mailman/listinfo/harbour
Re: [Harbour] QT - Multi-threading - A Limitation
Pritpal Bedi escreveu: Marcos Thanks for the explanation. I know about this facts but note that this operates on different widgets in the main thread. I am talking about different threads. Try this : oButton:Connect(clicked(), hb_threadStart( {|p|NewWindow()} ) ) With this line, don´t work: oButton:Connect(clicked(), hb_threadStart( {|p|NewWindow()} ) ) (the parameter is not a codeblock | may be a typo) But work with this: oButton:Connect(clicked(), {|p|hb_threadStart({||NewWindow()})} ) I am planning more tests. I believe we can find a solution. Regards, Marcos Gambeta ___ Harbour mailing list Harbour@harbour-project.org http://lists.harbour-project.org/mailman/listinfo/harbour
Re: [Harbour] QT - Multi-threading - A Limitation
Oh Marcos Gambeta wrote: With this line, don´t work: oButton:Connect(clicked(), hb_threadStart( {|p|NewWindow()} ) ) (the parameter is not a codeblock | may be a typo) But work with this: oButton:Connect(clicked(), {|p|hb_threadStart({||NewWindow()})} ) I am planning more tests. I believe we can find a solution. I put codeblock inside the function, pity on me. Your code is right. If it worked then for sure we can find a solution. Make one more test. Call the ThreadID() in both windows and see what these return, just in case... Regards Pritpal Bedi -- View this message in context: http://www.nabble.com/QT---Multi-threading---A-Limitation-tp23163007p23165158.html Sent from the Harbour - Dev mailing list archive at Nabble.com. ___ Harbour mailing list Harbour@harbour-project.org http://lists.harbour-project.org/mailman/listinfo/harbour
Re: [Harbour] QT - Multi-threading - A Limitation
Pritpal Bedi escreveu: If it worked then for sure we can find a solution. Make one more test. Call the ThreadID() in both windows and see what these return, just in case... Tested with these changes: ... ? threadid() oApplication:exec() ... ... ? threadid() oEventLoop:exec(0) ... First window (main) return 1. Each new window return a sequential number: 2, 3, 4, 5, 6, 7, ... Regards, Marcos Gambeta ___ Harbour mailing list Harbour@harbour-project.org http://lists.harbour-project.org/mailman/listinfo/harbour
Re: [Harbour] QT - Multi-threading - A Limitation
With change below ... oButton:Connect(clicked(), {|p|qout(hb_threadStart({||NewWindow()}))} ) ... i get a sequence like this: 0x01749118 0x0066F938 0x01C87998 0x01C8F400 Regards, Marcos Gambeta ___ Harbour mailing list Harbour@harbour-project.org http://lists.harbour-project.org/mailman/listinfo/harbour
Re: [Harbour] QT - Multi-threading - A Limitation
Perfect Marcos Gambeta wrote: With change below ... oButton:Connect(clicked(), {|p|qout(hb_threadStart({||NewWindow()}))} ) ... i get a sequence like this: 0x01749118 0x0066F938 0x01C87998 0x01C8F400 Means I have to investigate further what else GTQTC needs to simulate this behavior. Can you review gtqtc.c and look into hbqt_init() calls, I mean where GT is being initialized? Regards Pritpal Bedi -- View this message in context: http://www.nabble.com/QT---Multi-threading---A-Limitation-tp23163007p23166623.html Sent from the Harbour - Dev mailing list archive at Nabble.com. ___ Harbour mailing list Harbour@harbour-project.org http://lists.harbour-project.org/mailman/listinfo/harbour
Re: [Harbour] QT - Multi-threading - A Limitation
Thanks Marcos Marcos Gambeta wrote: Using QEventLoop, i can have 'n' windows, each window with your own event loop. Your tip has solved this issue. Now GTQTC is MT compatible. Will be posting changes in a little while. Hello Harbour family, Be prepared to match your applications with any other in the world. Regards Pritpal Bedi -- View this message in context: http://www.nabble.com/QT---Multi-threading---A-Limitation-tp23163007p23168426.html Sent from the Harbour - Dev mailing list archive at Nabble.com. ___ Harbour mailing list Harbour@harbour-project.org http://lists.harbour-project.org/mailman/listinfo/harbour