x64 issue, replace int for bufferid by bufferid itself, otherwise x64 crashes as bufferid aka buffer * differs from int under x64

This commit is contained in:
Christian Grasser 2015-06-08 12:11:10 +02:00
parent 581c7b2a72
commit edfa987f4e
8 changed files with 44 additions and 41 deletions

View File

@ -228,13 +228,13 @@ enum winVer{WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, WV
// allocate fullFilePath with the return values + 1, then call it again to get full path file name
#define NPPM_GETBUFFERIDFROMPOS (NPPMSG + 59)
// INT NPPM_GETBUFFERIDFROMPOS(INT index, INT iView)
// LRESULT NPPM_GETBUFFERIDFROMPOS(INT index, INT iView)
// wParam: Position of document
// lParam: View to use, 0 = Main, 1 = Secondary
// Returns 0 if invalid
#define NPPM_GETCURRENTBUFFERID (NPPMSG + 60)
// INT NPPM_GETCURRENTBUFFERID(0, 0)
// LRESULT NPPM_GETCURRENTBUFFERID(0, 0)
// Returns active Buffer
#define NPPM_RELOADBUFFERID (NPPMSG + 61)

View File

@ -3197,7 +3197,7 @@ void Notepad_plus::loadBufferIntoView(BufferID id, int whichOne, bool dontClose)
activateBuffer(id, whichOne); //activate. DocTab already activated but not a problem
MainFileManager->closeBuffer(idToClose, viewToOpen); //delete the buffer
if (_pFileSwitcherPanel)
_pFileSwitcherPanel->closeItem((int)idToClose, whichOne);
_pFileSwitcherPanel->closeItem(idToClose, whichOne);
}
else
{
@ -4730,7 +4730,7 @@ void Notepad_plus::notifyBufferChanged(Buffer * buffer, int mask)
}
if (_pFileSwitcherPanel)
_pFileSwitcherPanel->setItemIconStatus((int)buffer);
_pFileSwitcherPanel->setItemIconStatus(buffer);
if (!mainActive && !subActive)
{
@ -4830,7 +4830,7 @@ void Notepad_plus::notifyBufferActivated(BufferID bufid, int view)
if (_pFileSwitcherPanel)
{
_pFileSwitcherPanel->activateItem((int)bufid, currentView());
_pFileSwitcherPanel->activateItem(bufid, currentView());
}
if (_pDocMap && (!_pDocMap->isClosed()) && _pDocMap->isVisible())

View File

@ -101,7 +101,7 @@ void Notepad_plus::command(int id)
if (id == IDM_FILESWITCHER_FILESCLOSEOTHERS)
{
// Get current buffer and its view
_pFileSwitcherPanel->activateItem(int(_pEditView->getCurrentBufferID()), currentView());
_pFileSwitcherPanel->activateItem(_pEditView->getCurrentBufferID(), currentView());
}
}
break;

View File

@ -244,7 +244,7 @@ BufferID Notepad_plus::doOpen(const TCHAR *fileName, bool isRecursive, bool isRe
scnN.nmhdr.code = NPPN_FILEOPENED;
_pluginsManager.notify(&scnN);
if (_pFileSwitcherPanel)
_pFileSwitcherPanel->newItem((int)buf, currentView());
_pFileSwitcherPanel->newItem(buf, currentView());
}
else
{
@ -449,14 +449,14 @@ void Notepad_plus::doClose(BufferID id, int whichOne, bool doDeleteBackup)
//Do all the works
bool isBufRemoved = removeBufferFromView(id, whichOne);
int hiddenBufferID = -1;
BufferID hiddenBufferID = BUFFER_INVALID;
if (nrDocs == 1 && canHideView(whichOne))
{ //close the view if both visible
hideView(whichOne);
// if the current activated buffer is in this view,
// then get buffer ID to remove the entry from File Switcher Pannel
hiddenBufferID = ::SendMessage(_pPublicInterface->getHSelf(), NPPM_GETBUFFERIDFROMPOS, 0, whichOne);
hiddenBufferID = reinterpret_cast<BufferID>(::SendMessage(_pPublicInterface->getHSelf(), NPPM_GETBUFFERIDFROMPOS, 0, whichOne));
}
// Notify plugins that current file is closed
@ -466,15 +466,15 @@ void Notepad_plus::doClose(BufferID id, int whichOne, bool doDeleteBackup)
_pluginsManager.notify(&scnN);
// The document could be clonned.
// if the same buffer ID is not found then remove the entry from File Switcher Pannel
// if the same buffer ID is not found then remove the entry from File Switcher Panel
if (_pFileSwitcherPanel)
{
//int posInfo = ::SendMessage(_pPublicInterface->getHSelf(), NPPM_GETPOSFROMBUFFERID, (WPARAM)id ,0);
_pFileSwitcherPanel->closeItem((int)id, whichOne);
_pFileSwitcherPanel->closeItem(id, whichOne);
if (hiddenBufferID != -1)
_pFileSwitcherPanel->closeItem((int)hiddenBufferID, whichOne);
if (hiddenBufferID != BUFFER_INVALID)
_pFileSwitcherPanel->closeItem(hiddenBufferID, whichOne);
}
}
command(IDM_VIEW_REFRESHTABAR);

View File

@ -205,15 +205,15 @@ BOOL CALLBACK VerticalFileSwitcher::run_dlgProc(UINT message, WPARAM wParam, LPA
void VerticalFileSwitcher::activateDoc(TaskLstFnStatus *tlfs) const
{
int view = tlfs->_iView;
int bufferID = (int)tlfs->_bufID;
BufferID bufferID = static_cast<BufferID>(tlfs->_bufID);
int currentView = ::SendMessage(_hParent, NPPM_GETCURRENTVIEW, 0, 0);
int currentBufID = ::SendMessage(_hParent, NPPM_GETCURRENTBUFFERID, 0, 0);
BufferID currentBufID = reinterpret_cast<BufferID>(::SendMessage(_hParent, NPPM_GETCURRENTBUFFERID, 0, 0));
if (bufferID == currentBufID && view == currentView)
return;
int docPosInfo = ::SendMessage(_hParent, NPPM_GETPOSFROMBUFFERID, bufferID, view);
int docPosInfo = ::SendMessage(_hParent, NPPM_GETPOSFROMBUFFERID, (WPARAM)bufferID, view);
int view2set = docPosInfo >> 30;
int index2Switch = (docPosInfo << 2) >> 2 ;

View File

@ -55,19 +55,19 @@ public:
//Activate document in scintilla by using the internal index
void activateDoc(TaskLstFnStatus *tlfs) const;
int newItem(int bufferID, int iView){
int newItem(BufferID bufferID, int iView){
return _fileListView.newItem(bufferID, iView);
};
int closeItem(int bufferID, int iView){
int closeItem(BufferID bufferID, int iView){
return _fileListView.closeItem(bufferID, iView);
};
void activateItem(int bufferID, int iView) {
void activateItem(BufferID bufferID, int iView) {
_fileListView.activateItem(bufferID, iView);
};
void setItemIconStatus(int bufferID) {
void setItemIconStatus(BufferID bufferID) {
_fileListView.setItemIconStatus(bufferID) ;
};

View File

@ -157,11 +157,11 @@ void VerticalFileSwitcherListView::reload()
initList();
}
int VerticalFileSwitcherListView::getBufferInfoFromIndex(int index, int & view) const
BufferID VerticalFileSwitcherListView::getBufferInfoFromIndex(int index, int & view) const
{
int nbItem = ListView_GetItemCount(_hSelf);
if (index < 0 || index >= nbItem)
return -1;
return BUFFER_INVALID;
LVITEM item;
item.mask = LVIF_PARAM;
@ -170,10 +170,10 @@ int VerticalFileSwitcherListView::getBufferInfoFromIndex(int index, int & view)
TaskLstFnStatus *tlfs = (TaskLstFnStatus *)item.lParam;
view = tlfs->_iView;
return int(tlfs->_bufID);
return static_cast<BufferID>(tlfs->_bufID);
}
int VerticalFileSwitcherListView::newItem(int bufferID, int iView)
int VerticalFileSwitcherListView::newItem(BufferID bufferID, int iView)
{
int i = find(bufferID, iView);
if (i == -1)
@ -183,7 +183,7 @@ int VerticalFileSwitcherListView::newItem(int bufferID, int iView)
return i;
}
void VerticalFileSwitcherListView::setItemIconStatus(int bufferID)
void VerticalFileSwitcherListView::setItemIconStatus(BufferID bufferID)
{
Buffer *buf = (Buffer *)bufferID;
@ -207,7 +207,7 @@ void VerticalFileSwitcherListView::setItemIconStatus(int bufferID)
item.iItem = i;
ListView_GetItem(_hSelf, &item);
TaskLstFnStatus *tlfs = (TaskLstFnStatus *)(item.lParam);
if (int(tlfs->_bufID) == bufferID)
if (tlfs->_bufID == bufferID)
{
item.mask = LVIF_TEXT | LVIF_IMAGE;
ListView_SetItem(_hSelf, &item);
@ -236,7 +236,7 @@ generic_string VerticalFileSwitcherListView::getFullFilePath(size_t i) const
return tlfs->_fn;
}
int VerticalFileSwitcherListView::closeItem(int bufferID, int iView)
int VerticalFileSwitcherListView::closeItem(BufferID bufferID, int iView)
{
int i = find(bufferID, iView);
if (i != -1)
@ -244,7 +244,7 @@ int VerticalFileSwitcherListView::closeItem(int bufferID, int iView)
return i;
}
void VerticalFileSwitcherListView::activateItem(int bufferID, int iView)
void VerticalFileSwitcherListView::activateItem(BufferID bufferID, int iView)
{
// Clean all selection
int nbItem = ListView_GetItemCount(_hSelf);
@ -255,7 +255,7 @@ void VerticalFileSwitcherListView::activateItem(int bufferID, int iView)
ListView_SetItemState(_hSelf, i, LVIS_FOCUSED|LVIS_SELECTED, LVIS_FOCUSED|LVIS_SELECTED);
}
int VerticalFileSwitcherListView::add(int bufferID, int iView)
int VerticalFileSwitcherListView::add(BufferID bufferID, int iView)
{
int index = ListView_GetItemCount(_hSelf);
Buffer *buf = (Buffer *)bufferID;
@ -311,7 +311,7 @@ void VerticalFileSwitcherListView::removeAll()
}
}
int VerticalFileSwitcherListView::find(int bufferID, int iView) const
int VerticalFileSwitcherListView::find(BufferID bufferID, int iView) const
{
LVITEM item;
bool found = false;
@ -323,7 +323,7 @@ int VerticalFileSwitcherListView::find(int bufferID, int iView) const
item.iItem = i;
ListView_GetItem(_hSelf, &item);
TaskLstFnStatus *tlfs = (TaskLstFnStatus *)item.lParam;
if (int(tlfs->_bufID) == bufferID && tlfs->_iView == iView)
if (tlfs->_bufID == bufferID && tlfs->_iView == iView)
{
found = true;
break;
@ -374,7 +374,7 @@ std::vector<SwitcherFileInfo> VerticalFileSwitcherListView::getSelectedFiles(boo
ListView_GetItem(_hSelf, &item);
TaskLstFnStatus *tlfs = (TaskLstFnStatus *)item.lParam;
files.push_back(SwitcherFileInfo(int(tlfs->_bufID), tlfs->_iView));
files.push_back(SwitcherFileInfo(static_cast<BufferID>(tlfs->_bufID), tlfs->_iView));
}
}

View File

@ -32,13 +32,16 @@
#include "window.h"
#include "TaskListDlg.h"
class Buffer;
typedef Buffer * BufferID; //each buffer has unique ID by which it can be retrieved
#define SORT_DIRECTION_UP 0
#define SORT_DIRECTION_DOWN 1
struct SwitcherFileInfo {
int _bufID;
BufferID _bufID;
int _iView;
SwitcherFileInfo(int buf, int view): _bufID(buf), _iView(view){};
SwitcherFileInfo(BufferID buf, int view) : _bufID(buf), _iView(view){};
};
class VerticalFileSwitcherListView : public Window
@ -50,14 +53,14 @@ public:
virtual void init(HINSTANCE hInst, HWND parent, HIMAGELIST hImaLst);
virtual void destroy();
void initList();
int getBufferInfoFromIndex(int index, int & view) const;
BufferID getBufferInfoFromIndex(int index, int & view) const;
void setBgColour(int i) {
ListView_SetItemState(_hSelf, i, LVIS_SELECTED|LVIS_FOCUSED, 0xFF);
}
int newItem(int bufferID, int iView);
int closeItem(int bufferID, int iView);
void activateItem(int bufferID, int iView);
void setItemIconStatus(int bufferID);
int newItem(BufferID bufferID, int iView);
int closeItem(BufferID bufferID, int iView);
void activateItem(BufferID bufferID, int iView);
void setItemIconStatus(BufferID bufferID);
generic_string getFullFilePath(size_t i) const;
void insertColumn(const TCHAR *name, int width, int index);
@ -92,8 +95,8 @@ protected:
return (((VerticalFileSwitcherListView *)(::GetWindowLongPtr(hwnd, GWLP_USERDATA)))->runProc(hwnd, Message, wParam, lParam));
};
int find(int bufferID, int iView) const;
int add(int bufferID, int iView);
int find(BufferID bufferID, int iView) const;
int add(BufferID bufferID, int iView);
void remove(int index);
void removeAll();
};