From: <zou...@us...> - 2008-03-07 00:20:21
|
Revision: 1029 http://dcplusplus.svn.sourceforge.net/dcplusplus/?rev=1029&view=rev Author: zouzou123gen Date: 2008-03-06 16:20:14 -0800 (Thu, 06 Mar 2008) Log Message: ----------- fix DL queue crash, don't sub-class scrollbar menus Modified Paths: -------------- dcplusplus/trunk/changelog.txt dcplusplus/trunk/win32/QueueFrame.cpp dcplusplus/trunk/win32/QueueFrame.h dcplusplus/trunk/win32/WidgetTextBox.cpp Modified: dcplusplus/trunk/changelog.txt =================================================================== --- dcplusplus/trunk/changelog.txt 2008-03-06 19:43:56 UTC (rev 1028) +++ dcplusplus/trunk/changelog.txt 2008-03-07 00:20:14 UTC (rev 1029) @@ -42,6 +42,7 @@ * [L#194696] Fixed small memory leak * Some unix compile fixes (thanks pavel andreev and yakov suraev) * [L#199192] [NMDC] Fixed crash on empty private message +* [L#198416] Fixed crash when closing the download queue (poy) -- 0.704 2007-12-14 -- * Hub lists added to utilize Coral's distributed network (ullner) Modified: dcplusplus/trunk/win32/QueueFrame.cpp =================================================================== --- dcplusplus/trunk/win32/QueueFrame.cpp 2008-03-06 19:43:56 UTC (rev 1028) +++ dcplusplus/trunk/win32/QueueFrame.cpp 2008-03-07 00:20:14 UTC (rev 1029) @@ -70,17 +70,20 @@ { dirs = SmartWin::WidgetCreator<WidgetDirs>::create(this, WinUtil::Seeds::treeView); addWidget(dirs); + paned->setFirst(dirs); + dirs->setColor(WinUtil::textColor, WinUtil::bgColor); dirs->setNormalImageList(WinUtil::fileImages); + dirs->onSelectionChanged(std::tr1::bind(&QueueFrame::updateFiles, this)); dirs->onKeyDown(std::tr1::bind(&QueueFrame::handleKeyDownDirs, this, _1)); dirs->onContextMenu(std::tr1::bind(&QueueFrame::handleDirsContextMenu, this, _1)); - paned->setFirst(dirs); } { files = SmartWin::WidgetCreator<WidgetFiles>::create(this, WinUtil::Seeds::listView); - addWidget(files); + addWidget(files, true); + paned->setSecond(files); files->setSmallImageList(WinUtil::fileImages); files->createColumns(WinUtil::getStrings(columnNames)); @@ -92,8 +95,6 @@ files->onKeyDown(std::tr1::bind(&QueueFrame::handleKeyDownFiles, this, _1)); files->onSelectionChanged(std::tr1::bind(&QueueFrame::updateStatus, this)); files->onContextMenu(std::tr1::bind(&QueueFrame::handleFilesContextMenu, this, _1)); - - paned->setSecond(files); } { @@ -111,7 +112,7 @@ QueueManager::getInstance()->unlockQueue(); QueueManager::getInstance()->addListener(this); - onSpeaker(std::tr1::bind(&QueueFrame::handleSpeaker, this, _1, _2)); + onSpeaker(std::tr1::bind(&QueueFrame::handleSpeaker, this)); updateStatus(); layout(); @@ -121,7 +122,7 @@ } -HRESULT QueueFrame::handleSpeaker(WPARAM, LPARAM) { +LRESULT QueueFrame::handleSpeaker() { TaskQueue::List t; tasks.get(t); Modified: dcplusplus/trunk/win32/QueueFrame.h =================================================================== --- dcplusplus/trunk/win32/QueueFrame.h 2008-03-06 19:43:56 UTC (rev 1028) +++ dcplusplus/trunk/win32/QueueFrame.h 2008-03-07 00:20:14 UTC (rev 1029) @@ -27,12 +27,10 @@ #include <dcpp/FastAlloc.h> #include <dcpp/QueueManagerListener.h> #include <dcpp/QueueItem.h> -#include <dcpp/ClientListener.h> #include "resource.h" -class QueueFrame : - public StaticFrame<QueueFrame>, - private ClientListener, +class QueueFrame : + public StaticFrame<QueueFrame>, private QueueManagerListener { public: @@ -277,12 +275,12 @@ bool addUsers(const WidgetMenuPtr& menu, unsigned int startId, void (QueueFrame::*handler)(const UserPtr&), const QueueItem::SourceList& sources, bool offline); void layout(); - HRESULT handleSpeaker(WPARAM wParam, LPARAM lParam); + bool preClosing(); void postClosing(); void handleShowTreeClicked(); - + LRESULT handleSpeaker(); void handleMove(); void handleRemove(); void handlePriority(unsigned id); Modified: dcplusplus/trunk/win32/WidgetTextBox.cpp =================================================================== --- dcplusplus/trunk/win32/WidgetTextBox.cpp 2008-03-06 19:43:56 UTC (rev 1028) +++ dcplusplus/trunk/win32/WidgetTextBox.cpp 2008-03-07 00:20:14 UTC (rev 1029) @@ -25,6 +25,12 @@ WidgetTextBox::WidgetTextBox( SmartWin::Widget * parent ) : BaseType(parent), menuOpened(false) { this->onLeftMouseDblClick(std::tr1::bind(&WidgetTextBox::handleLeftDblClick, this, _1)); + /* + * unlike usual controls, the edit control doesn't send WM_INITMENUPOPUP when its standard + * menu is being opened. however, we can catch WM_ENTERIDLE and sub-class the menu then. + * + * method described by Jeff Partch in http://groups.google.com/group/microsoft.public.vc.mfc/msg/5e07dc60be3d3baa + */ this->onRaw(std::tr1::bind(&WidgetTextBox::handleEnterIdle, this, _1, _2), SmartWin::Message(WM_ENTERIDLE)); this->onRaw(std::tr1::bind(&WidgetTextBox::handleMenuSelect, this, _1, _2), SmartWin::Message(WM_MENUSELECT)); } @@ -35,8 +41,27 @@ LRESULT WidgetTextBox::handleEnterIdle(WPARAM wParam, LPARAM lParam) { if(wParam == MSGF_MENU && !menuOpened) { - menu = SmartWin::WidgetCreator<SmartWin::WidgetMenu>::attach(this, reinterpret_cast<HMENU>(::SendMessage(reinterpret_cast<HWND>(lParam), MN_GETHMENU, 0, 0)), WinUtil::Seeds::menu); - menuOpened = true; + GUITHREADINFO gti = { sizeof(gti) }; + if(::GetGUIThreadInfo(NULL, >i) && (gti.flags & GUI_POPUPMENUMODE) && (gti.hwndMenuOwner == handle())) { + HMENU hMenu = reinterpret_cast<HMENU>(::SendMessage(reinterpret_cast<HWND>(lParam), MN_GETHMENU, 0, 0)); + if(!hMenu) + return 0; + + menuOpened = true; + + { + // make sure we're not sub-classing the scrollbar context menu... + DWORD messagePos = ::GetMessagePos(); + POINT pt = { GET_X_LPARAM(messagePos), GET_Y_LPARAM(messagePos) }; + SCROLLBARINFO sbi = { sizeof(sbi) }; + if(::GetScrollBarInfo(handle(), OBJID_HSCROLL, &sbi) && ::PtInRect(&sbi.rcScrollBar, pt)) + return 0; + if(::GetScrollBarInfo(handle(), OBJID_VSCROLL, &sbi) && ::PtInRect(&sbi.rcScrollBar, pt)) + return 0; + } + + menu = SmartWin::WidgetCreator<SmartWin::WidgetMenu>::attach(this, hMenu, WinUtil::Seeds::menu); + } } return 0; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |