[Kde-bindings] KDE/kdebindings/ruby/qtruby
Arno Rehn
kde at arnorehn.de
Fri Jun 20 18:33:59 UTC 2008
SVN commit 822592 by arnorehn:
* Fix bug reported by Stefano Crocco. qt_metacall tried to write
data via an uninitialized pointer.
CCMAIL: kde-bindings at kde.org
M +5 -0 ChangeLog
M +9 -1 src/Qt.cpp
M +30 -0 src/marshall_types.cpp
M +1 -0 src/marshall_types.h
--- trunk/KDE/kdebindings/ruby/qtruby/ChangeLog #822591:822592
@@ -1,3 +1,8 @@
+2008-06-20 Arno Rehn <arno at arnorehn.de>
+
+ * Fix bug reported by Stefano Crocco. qt_metacall tried to write
+ data via an uninitialized pointer.
+
2008-06-20 Richard Dale <richard.j.dale at gmail.com>
* Partly fix bug reported by Stefan Crocco - this explains why a slot
--- trunk/KDE/kdebindings/ruby/qtruby/src/Qt.cpp #822591:822592
@@ -356,6 +356,11 @@
_called = true;
void ** o = new void*[_items];
smokeStackToQtStack(_stack, o + 1, 1, _items, _args);
+ void * ptr;
+ prepareQtReturnValue(*_args[0], _stack, o);
+ if (o[0] == 0 && arg.argType != xmoc_void)
+ o[0] = &ptr;
+
_obj->metaObject()->activate(_obj, _id, o);
if (_args[0]->argType != xmoc_void) {
@@ -409,7 +414,10 @@
void ** o = new void*[_items];
smokeStackToQtStack(_stack, o + 1, 1, _items, _args);
void * ptr;
- o[0] = &ptr;
+ prepareQtReturnValue(*_args[0], _stack, o);
+ if (o[0] == 0 && arg.argType != xmoc_void)
+ o[0] = &ptr;
+
_obj->qt_metacall(QMetaObject::InvokeMetaMethod, _id, o);
if (_args[0]->argType != xmoc_void) {
--- trunk/KDE/kdebindings/ruby/qtruby/src/marshall_types.cpp #822591:822592
@@ -18,6 +18,7 @@
#include "marshall_types.h"
#include <rubysig.h>
+#include <smoke/qt_smoke.h>
// This is based on the SWIG SWIG_INIT_STACK and SWIG_RELEASE_STACK macros.
// If RUBY_INIT_STACK is only called when an embedded extension such as, a
@@ -299,6 +300,35 @@
}
}
+void prepareQtReturnValue(const MocArgument& arg, Smoke::Stack stack, void** o)
+{
+ o[0] = 0;
+
+ if (arg.argType == xmoc_ptr) {
+ QString type(arg.st.name());
+ type = type.trimmed();
+ if (!type.endsWith('*')) { // a real pointer type, so a simple void* will do
+ type.remove('&');
+ const char* className = (const char*) type.toLatin1();
+ Smoke::ModuleIndex ci = qt_Smoke->findClass(className);
+ if (ci.index) {
+ Smoke::ModuleIndex mi = ci.smoke->findMethod(className, className);
+ if (mi.index) {
+ Smoke::Class& c = ci.smoke->classes[ci.index];
+ Smoke::Method& meth = mi.smoke->methods[mi.smoke->methodMaps[mi.index].method];
+ Smoke::StackItem _stack[1];
+ c.classFn(meth.method, 0, _stack);
+ o[0] = _stack[0].s_voidp;
+ }
+ }
+ }
+ } else if (arg.argType == xmoc_QString) {
+ o[0] = new QString;
+ } else if (arg.argType != xmoc_void) {
+ o[0] = &stack[0];
+ }
+}
+
MethodReturnValueBase::MethodReturnValueBase(Smoke *smoke, Smoke::Index meth, Smoke::Stack stack) :
_smoke(smoke), _method(meth), _stack(stack)
{
--- trunk/KDE/kdebindings/ruby/qtruby/src/marshall_types.h #822591:822592
@@ -30,6 +30,7 @@
#include "smokeruby.h"
Marshall::HandlerFn getMarshallFn(const SmokeType &type);
+void prepareQtReturnValue(const MocArgument& arg, Smoke::Stack stack, void** o);
extern void smokeStackToQtStack(Smoke::Stack stack, void ** o, int start, int end, QList<MocArgument*> args);
extern void smokeStackFromQtStack(Smoke::Stack stack, void ** _o, int start, int end, QList<MocArgument*> args);
More information about the Kde-bindings
mailing list