fixed crash on desktop and web mode

preferencesAboutTextFull
Claudio Valerio 12 years ago
parent dc923f8d17
commit 6d109d8da4
  1. 7
      Sankore_3.1.pro
  2. 64
      src/gui/UBScreenMirror.cpp

@ -292,42 +292,36 @@ macx {
TRANSLATION_ar.path = "$$RESOURCES_DIR/ar.lproj" TRANSLATION_ar.path = "$$RESOURCES_DIR/ar.lproj"
QMAKE_BUNDLE_DATA += TRANSLATION_ar QMAKE_BUNDLE_DATA += TRANSLATION_ar
} }
exists(resources/i18n/sankore_iw.qm) { exists(resources/i18n/sankore_iw.qm) {
TRANSLATION_iw.files = resources/i18n/sankore_iw.qm \ TRANSLATION_iw.files = resources/i18n/sankore_iw.qm \
resources/i18n/Localizable.strings resources/i18n/Localizable.strings
TRANSLATION_iw.path = "$$RESOURCES_DIR/iw.lproj" TRANSLATION_iw.path = "$$RESOURCES_DIR/iw.lproj"
QMAKE_BUNDLE_DATA += TRANSLATION_iw QMAKE_BUNDLE_DATA += TRANSLATION_iw
} }
exists(resources/i18n/sankore_pt.qm) { exists(resources/i18n/sankore_pt.qm) {
TRANSLATION_pt.files = resources/i18n/sankore_pt.qm \ TRANSLATION_pt.files = resources/i18n/sankore_pt.qm \
resources/i18n/Localizable.strings resources/i18n/Localizable.strings
TRANSLATION_pt.path = "$$RESOURCES_DIR/pt.lproj" TRANSLATION_pt.path = "$$RESOURCES_DIR/pt.lproj"
QMAKE_BUNDLE_DATA += TRANSLATION_pt QMAKE_BUNDLE_DATA += TRANSLATION_pt
} }
exists(resources/i18n/sankore_sk.qm) { exists(resources/i18n/sankore_sk.qm) {
TRANSLATION_sk.files = resources/i18n/sankore_sk.qm \ TRANSLATION_sk.files = resources/i18n/sankore_sk.qm \
resources/i18n/Localizable.strings resources/i18n/Localizable.strings
TRANSLATION_sk.path = "$$RESOURCES_DIR/sk.lproj" TRANSLATION_sk.path = "$$RESOURCES_DIR/sk.lproj"
QMAKE_BUNDLE_DATA += TRANSLATION_sk QMAKE_BUNDLE_DATA += TRANSLATION_sk
} }
exists(resources/i18n/sankore_bg.qm) { exists(resources/i18n/sankore_bg.qm) {
TRANSLATION_bg.files = resources/i18n/sankore_bg.qm \ TRANSLATION_bg.files = resources/i18n/sankore_bg.qm \
resources/i18n/Localizable.strings resources/i18n/Localizable.strings
TRANSLATION_bg.path = "$$RESOURCES_DIR/bg.lproj" TRANSLATION_bg.path = "$$RESOURCES_DIR/bg.lproj"
QMAKE_BUNDLE_DATA += TRANSLATION_bg QMAKE_BUNDLE_DATA += TRANSLATION_bg
} }
exists(resources/i18n/sankore_ca.qm) { exists(resources/i18n/sankore_ca.qm) {
TRANSLATION_ca.files = resources/i18n/sankore_ca.qm \ TRANSLATION_ca.files = resources/i18n/sankore_ca.qm \
resources/i18n/Localizable.strings resources/i18n/Localizable.strings
TRANSLATION_ca.path = "$$RESOURCES_DIR/ca.lproj" TRANSLATION_ca.path = "$$RESOURCES_DIR/ca.lproj"
QMAKE_BUNDLE_DATA += TRANSLATION_ca QMAKE_BUNDLE_DATA += TRANSLATION_ca
} }
exists(resources/i18n/sankore_el.qm) { exists(resources/i18n/sankore_el.qm) {
TRANSLATION_el.files = resources/i18n/sankore_el.qm \ TRANSLATION_el.files = resources/i18n/sankore_el.qm \
resources/i18n/Localizable.strings resources/i18n/Localizable.strings
@ -346,7 +340,6 @@ macx {
translation_cs.path = "$$resources_dir/cs.lproj" translation_cs.path = "$$resources_dir/cs.lproj"
qmake_bundle_data += translation_cs qmake_bundle_data += translation_cs
} }
exists(resources/i18n/sankore_mg.qm) { exists(resources/i18n/sankore_mg.qm) {
translation_mg.files = resources/i18n/sankore_mg.qm \ translation_mg.files = resources/i18n/sankore_mg.qm \
resources/i18n/localizable.strings resources/i18n/localizable.strings

@ -80,35 +80,41 @@ void UBScreenMirror::timerEvent(QTimerEvent *event)
void UBScreenMirror::grabPixmap() void UBScreenMirror::grabPixmap()
{ {
if (mSourceWidget) // if (mSourceWidget)
{ // {
QPoint topLeft = mSourceWidget->mapToGlobal(mSourceWidget->geometry().topLeft()); // QPoint topLeft = mSourceWidget->mapToGlobal(mSourceWidget->geometry().topLeft());
QPoint bottomRight = mSourceWidget->mapToGlobal(mSourceWidget->geometry().bottomRight()); // QPoint bottomRight = mSourceWidget->mapToGlobal(mSourceWidget->geometry().bottomRight());
mRect.setTopLeft(topLeft); // mRect.setTopLeft(topLeft);
mRect.setBottomRight(bottomRight); // mRect.setBottomRight(bottomRight);
} // }
// get image of desktop // // get image of desktop
WId windowID = qApp->desktop()->screen(mScreenIndex)->winId(); // WId windowID = qApp->desktop()->screen(mScreenIndex)->winId();
#if defined(Q_WS_MAC) // qDebug() << windowID;
// Available in Mac OS X v10.6 and later. //#if defined(Q_WS_MAC)
CGRect grabRect;
grabRect.origin.x = mRect.x(); // TODO: bad mac fix. On dual screen mac os x and let web mode for more than one minute and it crashed
grabRect.origin.y = mRect.y(); // NSAutorelease pull should avoid this.
grabRect.size.width = mRect.width();
grabRect.size.height = mRect.height(); // // Available in Mac OS X v10.6 and later.
CGImageRef windowImage = CGWindowListCreateImage(grabRect // CGRect grabRect;
,kCGWindowListOptionOnScreenOnly // grabRect.origin.x = mRect.x();
,windowID // grabRect.origin.y = mRect.y();
,kCGWindowImageDefault); // grabRect.size.width = mRect.width();
// grabRect.size.height = mRect.height();
mLastPixmap = QPixmap::fromMacCGImageRef(windowImage); // CGImageRef windowImage = CGWindowListCreateImage(grabRect
#else // ,kCGWindowListOptionOnScreenOnly
// ,windowID
mLastPixmap = QPixmap::grabWindow(windowID, mRect.x(), mRect.y(), mRect.width(), mRect.height()); // ,kCGWindowImageDefault);
#endif
// mLastPixmap = QPixmap::fromMacCGImageRef(windowImage);
//#else
// mLastPixmap = QPixmap::grabWindow(windowID, mRect.x(), mRect.y(), mRect.width(), mRect.height());
//#endif
mLastPixmap = QPixmap::grabWidget(mSourceWidget);
mLastPixmap = mLastPixmap.scaled(width(), height(), Qt::KeepAspectRatio, Qt::SmoothTransformation); mLastPixmap = mLastPixmap.scaled(width(), height(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
} }

Loading…
Cancel
Save