Fix SEGV on start and race conditions when using the popup menu from the toolbar

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
pull/1/head
Michele Calgaro 2 months ago
parent 4a065bb4cd
commit 014348eb15
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -8,5 +8,6 @@
#cmakedefine WORDS_BIGENDIAN @WORDS_BIGENDIAN@ #cmakedefine WORDS_BIGENDIAN @WORDS_BIGENDIAN@
// Zlibrary defines // Zlibrary defines
#define BASEDIR "@SHARE_INSTALL_PREFIX@" #define BASEDIR "@DATA_INSTALL_DIR@"
#define IMAGEDIR "@SHARE_INSTALL_PREFIX@/pixmaps" #define IMAGEDIR "@DATA_INSTALL_DIR@/tde-ebook-reader/icons"
#define ZLBASEDIR "@ZL_SHARE_INSTALL_PREFIX@"

@ -85,7 +85,7 @@ Reader &Reader::Instance() {
} }
Reader::Reader(const std::string &bookToOpen) : Reader::Reader(const std::string &bookToOpen) :
ZLApplication("Reader"), ZLApplication("tde-ebook-reader"),
QuitOnCancelOption(ZLCategoryKey::CONFIG, OPTIONS, "QuitOnCancel", false), QuitOnCancelOption(ZLCategoryKey::CONFIG, OPTIONS, "QuitOnCancel", false),
KeyScrollingDelayOption(ZLCategoryKey::CONFIG, "Scrollings", "Delay", 0, 2000, 100), KeyScrollingDelayOption(ZLCategoryKey::CONFIG, "Scrollings", "Delay", 0, 2000, 100),
LinesToScrollOption(ZLCategoryKey::CONFIG, "SmallScrolling", "LinesToScroll", 1, 20, 1), LinesToScrollOption(ZLCategoryKey::CONFIG, "SmallScrolling", "LinesToScroll", 1, 20, 1),
@ -172,7 +172,7 @@ Reader::Reader(const std::string &bookToOpen) :
myOpenFileHandler = new OpenFileHandler(); myOpenFileHandler = new OpenFileHandler();
ZLCommunicationManager::Instance().registerHandler("openFile", myOpenFileHandler); ZLCommunicationManager::Instance().registerHandler("openFile", myOpenFileHandler);
ZLNetworkManager::Instance().setUserAgent(std::string("Reader/") + VERSION); //ZLNetworkManager::Instance().setUserAgent(std::string("Reader/") + VERSION);
} }
Reader::~Reader() { Reader::~Reader() {

@ -91,6 +91,7 @@ ZLTQtToolButton::ZLTQtToolButton(ZLTQtApplicationWindow &window, ZLToolbar::Abst
myWindow.myPopupIdMap[&menuButtonItem] = myWindow.myPopupIdMap[&menuButtonItem] =
popupData.isNull() ? (size_t)-1 : (popupData->id() - 1); popupData.isNull() ? (size_t)-1 : (popupData->id() - 1);
setPopup(new ZLTQtPopupMenu(this)); setPopup(new ZLTQtPopupMenu(this));
setPopupDelay(0);
} }
TQString text = TQString::fromUtf8(myItem.tooltip().c_str()); TQString text = TQString::fromUtf8(myItem.tooltip().c_str());
setTextLabel(text); setTextLabel(text);

@ -19,13 +19,20 @@
#include "ZLTQtPopupMenu.h" #include "ZLTQtPopupMenu.h"
#include "tqtimer.h"
ZLTQtPopupMenu::ZLTQtPopupMenu(TQWidget *parent) : TQPopupMenu(parent) { ZLTQtPopupMenu::ZLTQtPopupMenu(TQWidget *parent) : TQPopupMenu(parent) {
connect(this, TQ_SIGNAL(activated(int)), this, TQ_SLOT(onActivated(int))); connect(this, TQ_SIGNAL(activated(int)), this, TQ_SLOT(onActivated(int)));
} }
void ZLTQtPopupMenu::onActivated(int itemId) { void ZLTQtPopupMenu::onActivated(int itemId) {
myItemId = itemId;
TQTimer::singleShot(0, this, TQ_SLOT(doActivation()) );
}
void ZLTQtPopupMenu::doActivation() {
if (!myPopupData.isNull()) { if (!myPopupData.isNull()) {
myPopupData->run(myItemIdToIndex[itemId]); myPopupData->run(myItemIdToIndex[myItemId]);
} }
} }

@ -36,10 +36,12 @@ public:
private slots: private slots:
void onActivated(int itemId); void onActivated(int itemId);
void doActivation();
private: private:
shared_ptr<ZLPopupData> myPopupData; shared_ptr<ZLPopupData> myPopupData;
std::map<int,int> myItemIdToIndex; std::map<int,int> myItemIdToIndex;
int myItemId;
}; };
#endif /* __ZLTQTPOPUPMENU_H__ */ #endif /* __ZLTQTPOPUPMENU_H__ */

Loading…
Cancel
Save