Skip to content

Commit

Permalink
avoid the size of returned value Windows10 + Soft2015
Browse files Browse the repository at this point in the history
getQtSoftimageAnchor now returns value as CString and this pointer should be parsed long(ptr, 16) when using in python.
  • Loading branch information
yamahigashi committed Jul 1, 2016
1 parent d46a14c commit e87f74f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
7 changes: 7 additions & 0 deletions src/Qt/__init__.py
Expand Up @@ -208,6 +208,13 @@ def wrapinstance(ptr, base=None):
"""convert a pointer to a Qt class instance (PySide/PyQt compatible)"""
if ptr is None:
return None

if isinstance(ptr, str) or isinstance(ptr, unicode):
try:
ptr = long(ptr, 16)
except ValueError:
ptr = long(ptr, 10)

ptr = long(ptr) #Ensure type
if isPySide():
from PySide import shiboken
Expand Down
7 changes: 3 additions & 4 deletions src/QtSoftimage/qtsoftimage.cpp
Expand Up @@ -85,7 +85,7 @@ SICALLBACK
XSILoadPlugin(PluginRegistrar &reg)
{
reg.PutName("QtSoftimage");
reg.PutVersion(0,2);
reg.PutVersion(0,3);
reg.PutAuthor("Jonathan Benayoun");
reg.PutURL("www.jobenayoun.com");
reg.RegisterCommand("getQtSoftimageAnchor");
Expand All @@ -108,12 +108,11 @@ getQtSoftimageAnchor_Init(const CRef &ref)
return CStatus::OK;
}

SICALLBACK
getQtSoftimageAnchor_Execute(const CRef &ref)
SICALLBACK getQtSoftimageAnchor_Execute(const CRef &ref)
{
Context ctxt = Context(ref);
QWidget *anchor = QtSoftimage::getQtSoftimageAnchor();
ctxt.PutAttribute("ReturnValue", CValue(ULONG(anchor)));
ctxt.PutAttribute("ReturnValue", CString(anchor));
return CStatus::OK;
}

Expand Down
8 changes: 4 additions & 4 deletions src/pyqt_example.py
Expand Up @@ -154,21 +154,21 @@ def XSILoadPlugin( in_reg ):
def ExampleDialog_Execute():
"""a simple example dialog showing basic functionality of the pyqt for softimage plugin"""
sianchor = Application.getQtSoftimageAnchor()
sianchor = Qt.wrapinstance( long(sianchor), QWidget )
sianchor = Qt.wrapinstance( sianchor, QWidget )
dialog = ExampleDialog( sianchor )
dialog.show()

def ExampleSignalSlot_Execute():
"""a simple example showing softimage events triggering pyqt signals"""
sianchor = Application.getQtSoftimageAnchor()
sianchor = Qt.wrapinstance( long(sianchor), QWidget )
sianchor = Qt.wrapinstance( sianchor, QWidget )
dialog = ExampleSignalSlot( sianchor )
dialog.show()

def ExampleMenu_Execute():
"""a simple example showing the use of a qmenu"""
sianchor = Application.getQtSoftimageAnchor()
sianchor = Qt.wrapinstance( long(sianchor), QWidget )
sianchor = Qt.wrapinstance( sianchor, QWidget )
menu = ExampleMenu( sianchor )

# notice the use of QCursor and exec_ call
Expand All @@ -183,7 +183,7 @@ def ExampleUIFile_Execute():
return False

sianchor = Application.getQtSoftimageAnchor()
sianchor = Qt.wrapinstance( long(sianchor), QWidget )
sianchor = Qt.wrapinstance( sianchor, QWidget )
uifilepath = os.path.join(plugin.OriginPath, "exampleui.ui")
dialog = ExampleUIFile(sianchor, uifilepath)
dialog.show()

0 comments on commit e87f74f

Please sign in to comment.