From 8b0a7746bb20f4c71b10a756f4d09f66c16ea528 Mon Sep 17 00:00:00 2001 From: Jordan Lee Date: Sun, 16 Mar 2014 22:50:39 +0000 Subject: [PATCH] fix crash when creating the Open Torrent dialog in Qt 5.2 on Ubuntu 14.04 --- qt/mainwin.cc | 18 ++++++++++++++---- qt/qtr.pro | 2 +- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/qt/mainwin.cc b/qt/mainwin.cc index 30361edbd..90ea60264 100644 --- a/qt/mainwin.cc +++ b/qt/mainwin.cc @@ -1177,8 +1177,13 @@ TrMainWindow :: openTorrent () QCheckBox * b = new QCheckBox (tr ("Show &options dialog")); b->setChecked (myPrefs.getBool (Prefs::OPTIONS_PROMPT)); b->setObjectName (SHOW_OPTIONS_CHECKBOX_NAME); - QGridLayout * l = dynamic_cast (d->layout ()); - l->addWidget (b, l->rowCount (), 0, 1, -1, Qt::AlignLeft); + auto l = dynamic_cast (d->layout ()); + if (l == nullptr) + { + l = new QGridLayout; + d->setLayout (l); + } + l->addWidget (b, l->rowCount(), 0, 1, -1, Qt::AlignLeft); connect (d, SIGNAL (filesSelected (const QStringList&)), this, SLOT (addTorrents (const QStringList&))); @@ -1319,8 +1324,13 @@ TrMainWindow :: removeTorrents (const bool deleteFiles) msgBox.setStandardButtons (QMessageBox::Ok | QMessageBox::Cancel); msgBox.setDefaultButton (QMessageBox::Cancel); msgBox.setIcon (QMessageBox::Question); - /* hack needed to keep the dialog from being too narrow */ - QGridLayout* layout = (QGridLayout*)msgBox.layout (); + // hack needed to keep the dialog from being too narrow + auto layout = dynamic_cast(msgBox.layout()); + if (layout == nullptr) + { + layout = new QGridLayout; + msgBox.setLayout (layout); + } QSpacerItem* spacer = new QSpacerItem (450, 0, QSizePolicy::Minimum, QSizePolicy::Expanding); layout->addItem (spacer, layout->rowCount (), 0, 1, layout->columnCount ()); diff --git a/qt/qtr.pro b/qt/qtr.pro index 221a34bc2..f39005397 100644 --- a/qt/qtr.pro +++ b/qt/qtr.pro @@ -11,7 +11,7 @@ unix: INSTALLS += man man.path = /share/man/man1/ man.files = transmission-qt.1 -CONFIG += qt thread debug link_pkgconfig +CONFIG += qt thread debug link_pkgconfig c++11 QT += network dbus PKGCONFIG = fontconfig libcurl openssl libevent -- 2.40.0