Bug 189041 - [qyoto] QMouseEvent and Buttons() => exeption
Summary: [qyoto] QMouseEvent and Buttons() => exeption
Status: RESOLVED NOT A BUG
Alias: None
Product: bindings
Classification: Developer tools
Component: general (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR crash
Target Milestone: ---
Assignee: kde-bindings
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-04-07 17:12 UTC by yan
Modified: 2009-04-10 14:05 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description yan 2009-04-07 17:12:00 UTC
Version:            (using KDE 4.2.0)
OS:                Linux

under ubuntu,
when i try use QMouseEvent Buttons function an exeption is generate : cast invalid to uint..

code :

using System;
using Qyoto;

public class maWidget : QWidget
{
     //position dans le repere widget de click gauche
    QPoint p;
    bool b;

   
    public maWidget()
        : base(null, (uint)(Qt.WindowType.FramelessWindowHint | Qt.WindowType.SubWindow))
    {
        b = false;
       
        Resize(300,300);
        QBitmap mask = new QBitmap(5,5);
        {
            QPainter p = new QPainter(mask);
            p.FillRect(mask.Rect() , Qt.GlobalColor.color0);
            p.SetPen(Qt.GlobalColor.color1);
            for (int i = 0 ; i < mask.Height() ; ++i)
                for(int j = 0 ; j< mask.Width() ; ++j)
                    if( (i%2 ^ j%2) != 0)
                        p.DrawPoint(j,i);
        }

        mask = new QBitmap(mask.Scaled( this.Size ));

        SetMask(mask);

    }

    protected override void MousePressEvent   ( QMouseEvent  mouseEvent )
    {
        if(mouseEvent.Button() == Qt.MouseButton.LeftButton) 
        {
            p = mouseEvent.Pos();
            b = true;
        }
 
    }
    protected override void MouseReleaseEvent   ( QMouseEvent  mouseEvent )
    {
        if(mouseEvent.Button() == Qt.MouseButton.LeftButton) 
        {
            b = false;
        }
 
    }
    protected override void MouseMoveEvent  ( QMouseEvent  mouseEvent )
    {
       
        uint but = mouseEvent.Buttons(); // <= cast exeption

        if(b)    
        {
            QPoint po= mouseEvent.GlobalPos() - p;
            Move(po.X(),po.Y() );
        }
    }
}


public class Test
{
   
    public static int Main(String[] args)
    {
        QApplication app = new QApplication(args);
        maWidget w = new maWidget();
        w.Show();
        return QApplication.Exec();
    }
   
}
Comment 1 yan 2009-04-08 16:54:38 UTC
This bug is under ubuntu 8.04
Comment 2 Arno Rehn 2009-04-08 17:06:11 UTC
works perfectly for me. could you post the exact error message and backtrace for the crash?
Comment 3 yan 2009-04-08 17:17:10 UTC
i look my ubuntu version. It's 8.04. So i try an old mono and qyoto version. So it's certainly an old bug.


Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidCastException: Cannot cast from source type to destination type.
  at Qyoto.QMouseEvent.Buttons () [0x00000]
  at maWidget.MouseMoveEvent (Qyoto.QMouseEvent mouseEvent) [0x00000] in /home/mongaulois/testqyoto/testqyoto/test.cs:55
  at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (object,object[])
  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] --- End of inner exception stack trace ---

  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000]
  at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000]
  at Qyoto.SmokeInvocation.InvokeMethod (IntPtr instanceHandle, IntPtr methodHandle, IntPtr stack) [0x00000]
  at (wrapper native-to-managed) Qyoto.SmokeInvocation:InvokeMethod (intptr,intptr,intptr)
  at (wrapper managed-to-native) Qyoto.SmokeInvocation:CallSmokeMethod (int,intptr,intptr,int)
  at Qyoto.SmokeInvocation.Invoke (System.String mungedName, System.String signature, System.Type returnType, System.Object[] args) [0x00000]
  at Qyoto.QApplication.Exec () [0x00000]
  at Test.Main (System.String[] args) [0x00013] in /home/mongaulois/testqyoto/testqyoto/test.cs:74
Comment 4 yan 2009-04-10 14:05:23 UTC
i test ubuntu 9.04
all works perfectly :)