Re: [PyQt] APPCrash on exit, Qt4 MainWindow

2013-07-03 Thread Phil Thompson
On Wed, 3 Jul 2013 06:58:56 -0700 (PDT), egus  wrote:
> Thanks for the direction Phil.
> 
> I added sip.setdestroyonexit(False) to__init__ in my MainWindow class
and
> that appears to have negated the crashing on the two apps I tried it on.
> Simply commenting that command out again caused the same apps to crash
> after
> adding it.  So it's definitely the right direction.
> 
> My limited knowledge of sip, do I risk any memory leaks or other
unexpected
> behavior by bypassing the c++ destructor call this way? Are there any
> cleanup methods/calls I should add when setting setdestroyonexit to
False?

It depends on what your application does after the interpreter exits. If
it's just a Python script (ie. not embedded in a larger application) then
the process is about to terminate anyway. This is the default behaviour of
PyQt5.

Phil
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] APPCrash on exit, Qt4 MainWindow

2013-07-03 Thread egus
Thanks for the direction Phil.

I added sip.setdestroyonexit(False) to__init__ in my MainWindow class and
that appears to have negated the crashing on the two apps I tried it on.
Simply commenting that command out again caused the same apps to crash after
adding it.  So it's definitely the right direction.

My limited knowledge of sip, do I risk any memory leaks or other unexpected
behavior by bypassing the c++ destructor call this way? Are there any
cleanup methods/calls I should add when setting setdestroyonexit to False?

Thanks,
-egus




--
View this message in context: 
http://python.6.x6.nabble.com/APPCrash-on-exit-Qt4-MainWindow-tp5023351p5023518.html
Sent from the PyQt mailing list archive at Nabble.com.
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] APPCrash on exit, Qt4 MainWindow

2013-07-03 Thread Phil Thompson
On Tue, 2 Jul 2013 07:52:08 -0500, Erik  wrote:
> Python 2.7.4x32, Qt 4.8.4 (4.10.2-py27)x32 on Windows 7 64-bit OS PC's
> (multiple machines)
> 
> I'm having a reproducible APPCRASH (in QtGUI4.dll) on exit of any
> application I write that uses a QMainWindow and a menuBar, if the window
> contains > 10 other widgets.
> If I remove widgets down below the threshold (10), app closes normally.
> Whether I write it by hand or in QTDesigner, but if I include a menubar,
> blank or otherwise, App does not close properly in Windows resulting in
a
> 'close program' Windows dialog.
> 
> This happens on all 3 of my Windows 7 boxes here, but works fine in a
> instance of Windows XP on an older machine. (Same PyQt/Python versions)
> 
> An example with code would be I create a QMainWindow in QT Designer, put
12
> widgets of any combination on it. (In this example I added a menu bar in
my
> code, but works the same (crash) if I add it in QTDesigner.
> 
> 
> import sys
> from PyQt4 import QtGui
> import ui_mainwindow as UIMW
> 
> class MainWindow(QtGui.QMainWindow, UIMW.Ui_MainWindow):
> 
> def __init__(self):
> super(MainWindow, self).__init__()
> self.setupUi(self)
> 
> # MenuBar testing
> self.menubar = self.menuBar()
> menu = self.menubar.addMenu("Test")
> 
> app = QtGui.QApplication(sys.argv)
> window = MainWindow()
> window.show()
> sys.exit(app.exec_())
> 
> As long as my Ui_MainWindow has > 10 widgets + menuBar, I get:
>   Problem Event Name:APPCRASH
>   Application Name:python.exe
>   Application Version:0.0.0.0
>   Application Timestamp:51606175
>   Fault Module Name:QtGui4.dll
>   Fault Module Version:4.8.4.0
> 
> About 10% of the time, the first time I run the app, it will not crash
> until I run it again, click on some widgets, etc, and then exit.

Try experimenting with sip.setdestroyonexit().

Phil
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] [SIP] How to reasonably implement writable global variables?

2013-07-03 Thread Phil Thompson
On Wed, 3 Jul 2013 00:28:59 +0800, "Casper Ti. Vector"
 wrote:
> Hello list, I am a newcomer to SIP (only one day experience), and please
> tell me if I make a mistake.  Thanks :)
> 
> I found it quite hard to make read-write interface for (module-wide)
> global variables (other than explicitly writing C/C++ functions to get
and
> set them).  For example:
> 
> test.sip:
>> %Module test
>> %ModuleHeaderCode
>> #include "test.h"
>> %End
>> 
>> int test;
>> int get_test(void);
>> void set_test(int x);
> 
> test.h:
>> extern int test;
>> int get_test(void);
>> void set_test(int x);
> 
> test.cpp:
>> int test = 0;
>> int get_test(void) {
>>   return test;
>> }
>> void get_test(int x) {
>>   test = x;
>> }
> 
> test.py:
>> import test
>> print(test.test) # 0
>> print(test.get_test()) # 0
>> test.set_test(1)
>> print(test.test) # 0
>> print(test.get_test()) # 1
>> test.test = 2
>> print(test.test) # 2
>> print(test.get_test()) # 1
> 
> Thus `test' in python seems to be totally independently from its C++
> counterpart once it is formed.  However, if wrapped in a class, they
> would be bound together, and changes in one will affect the other.
> 
> So is there any elegant way to make global variables writable using
> the `var = val' syntax?  Any suggestions are welcome :)
> 
> P.S. I know python is object-oriented, but I think this particular
>  approach is still pratically useful in some situations (and OOP
>  itself is not a "silver bullet"), so it might not be meaningless to
>  implement this.

You can't do it. Python needs to support module level descriptors for it
to be implemented.

Phil
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt