diff options
author | George Hazan <george.hazan@gmail.com> | 2016-06-06 17:47:34 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2016-06-06 17:47:34 +0000 |
commit | b63eccef16eed4f73f2711b66fb93c0062dd0cf8 (patch) | |
tree | e9e16f69aae590c1a6eb8610a6d79c1bafcecd46 | |
parent | df1536b00473e18e2911911c5ec323a01c7f070b (diff) |
crash fix when one searches a contact using the disabled account
git-svn-id: http://svn.miranda-ng.org/main/trunk@16930 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | src/mir_app/src/searchresults.cpp | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/src/mir_app/src/searchresults.cpp b/src/mir_app/src/searchresults.cpp index 919db1eedd..27d0bc72f0 100644 --- a/src/mir_app/src/searchresults.cpp +++ b/src/mir_app/src/searchresults.cpp @@ -58,32 +58,34 @@ static const TCHAR *szColumnNames[] = { NULL, NULL, _T("Nick"), _T("First Name") static int defaultColumnSizes[] = { 0, 90, 100, 100, 100, 2000 };
void LoadColumnSizes(HWND hwndResults, const char *szProto)
{
- HDITEM hdi;
- int columnOrder[NUM_COLUMNID];
- int columnCount;
char szSetting[32];
- bool colOrdersValid;
defaultColumnSizes[COLUMNID_PROTO] = g_iIconSX + 4;
FindAddDlgData *dat = (FindAddDlgData*)GetWindowLongPtr(GetParent(hwndResults), GWLP_USERDATA);
- columnCount = NUM_COLUMNID;
- colOrdersValid = true;
+ int columnCount = NUM_COLUMNID, columnOrder[NUM_COLUMNID];
+ bool colOrdersValid = true;
for (int i = 0; i < NUM_COLUMNID; i++) {
LVCOLUMN lvc;
if (i < columnCount) {
- int bNeedsFree = FALSE;
+ bool bNeedsFree = false;
lvc.mask = LVCF_TEXT | LVCF_WIDTH;
if (szColumnNames[i] != NULL)
lvc.pszText = TranslateTS(szColumnNames[i]);
- else if (i == COLUMNID_HANDLE) {
- if (szProto) {
- bNeedsFree = TRUE;
- lvc.pszText = mir_a2t((char*)CallProtoServiceInt(NULL, szProto, PS_GETCAPS, PFLAG_UNIQUEIDTEXT, 0));
+ else {
+ if (i == COLUMNID_HANDLE) {
+ lvc.pszText = _T("ID");
+ if (szProto) {
+ INT_PTR ret = CallProtoServiceInt(NULL, szProto, PS_GETCAPS, PFLAG_UNIQUEIDTEXT, 0);
+ if (ret != CALLSERVICE_NOTFOUND) {
+ bNeedsFree = true;
+ lvc.pszText = mir_a2t((char*)ret);
+ }
+ }
}
- else lvc.pszText = _T("ID");
+ else lvc.mask &= ~LVCF_TEXT;
}
- else lvc.mask &= ~LVCF_TEXT;
+
mir_snprintf(szSetting, "ColWidth%d", i);
lvc.cx = db_get_w(NULL, "FindAdd", szSetting, defaultColumnSizes[i]);
ListView_InsertColumn(hwndResults, i, (LPARAM)&lvc);
@@ -101,9 +103,11 @@ void LoadColumnSizes(HWND hwndResults, const char *szProto) ListView_SetColumnOrderArray(hwndResults, columnCount, columnOrder);
dat->iLastColumnSortIndex = db_get_b(NULL, "FindAdd", "SortColumn", COLUMNID_NICK);
- if (dat->iLastColumnSortIndex >= columnCount) dat->iLastColumnSortIndex = COLUMNID_NICK;
+ if (dat->iLastColumnSortIndex >= columnCount)
+ dat->iLastColumnSortIndex = COLUMNID_NICK;
dat->bSortAscending = db_get_b(NULL, "FindAdd", "SortAscending", TRUE);
+ HDITEM hdi;
hdi.mask = HDI_FORMAT;
hdi.fmt = HDF_LEFT | HDF_STRING | (dat->bSortAscending ? HDF_SORTDOWN : HDF_SORTUP);
Header_SetItem(ListView_GetHeader(hwndResults), dat->iLastColumnSortIndex, &hdi);
|