qtoctave-0.10.1-initial_position.patch 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. Description: Fix crash when closing a dock tool within the first 5 seconds
  2. (a NULL pointer dereference caused by a race condition between the user
  3. closing the tool and the timer setting the initial positions, prevented by
  4. using a QWeakPointer instead of a raw QWidget *)
  5. Author: Kevin Kofler <kevin.kofler@chello.at>
  6. Bug-Fedora: https://bugzilla.redhat.com/show_bug.cgi?id=722986
  7. Forwarded: no
  8. Last-Update: 2011-10-06
  9. ---
  10. This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
  11. diff -ur qtoctave-0.10.1/qtoctave/src/main.cpp qtoctave-0.10.1-initialposition/qtoctave/src/main.cpp
  12. --- qtoctave-0.10.1/qtoctave/src/main.cpp 2011-01-06 22:48:07.000000000 +0100
  13. +++ qtoctave-0.10.1-initialposition/qtoctave/src/main.cpp 2011-10-06 20:17:03.000000000 +0200
  14. @@ -595,7 +595,7 @@
  15. initPos.maximized=maximized;
  16. initPos.minimized=minimized;
  17. initPos.widget=bw->parentWidget();
  18. - if(initPos.widget!=NULL)
  19. + if(!initPos.widget.isNull())
  20. initialPositionList.append(initPos);
  21. //bw->show();
  22. //bw->move(x,y);
  23. @@ -694,10 +694,14 @@
  24. {
  25. foreach(InitialPosition i, initialPositionList)
  26. {
  27. - i.widget->move(i.x,i.y);
  28. - i.widget->resize(i.width, i.height);
  29. - if(i.maximized) i.widget->showMaximized();
  30. - if(i.minimized) i.widget->showMinimized();
  31. + QWidget *widget = i.widget.data();
  32. + if (widget)
  33. + {
  34. + widget->move(i.x,i.y);
  35. + widget->resize(i.width, i.height);
  36. + if(i.maximized) widget->showMaximized();
  37. + if(i.minimized) widget->showMinimized();
  38. + }
  39. }
  40. }
  41. diff -ur qtoctave-0.10.1/qtoctave/src/main.h qtoctave-0.10.1-initialposition/qtoctave/src/main.h
  42. --- qtoctave-0.10.1/qtoctave/src/main.h 2011-01-06 22:48:08.000000000 +0100
  43. +++ qtoctave-0.10.1-initialposition/qtoctave/src/main.h 2011-10-06 20:12:55.000000000 +0200
  44. @@ -27,6 +27,7 @@
  45. #include <QListWidget>
  46. #include <QTimer>
  47. #include <QVector>
  48. +#include <QWeakPointer>
  49. #include "mainwindow.h"
  50. #include "octave_connection.h"
  51. #include "terminal.h"
  52. @@ -41,7 +42,7 @@
  53. struct InitialPosition
  54. {
  55. int x, y, width, height;
  56. - QWidget *widget;
  57. + QWeakPointer<QWidget> widget;
  58. bool maximized, minimized;
  59. };