summaryrefslogtreecommitdiff
path: root/plugins/Popup
diff options
context:
space:
mode:
authorTobias Weimer <wishmaster51@googlemail.com>2015-04-21 19:33:14 +0000
committerTobias Weimer <wishmaster51@googlemail.com>2015-04-21 19:33:14 +0000
commit0d2f2928952c7bbebf163662fd4c8e3683c4e066 (patch)
tree3a17f5a0995226fc7d346d3d2c38505fb2f1ecd3 /plugins/Popup
parent6bf05d34ba416ec14f651c22cba8710e52125907 (diff)
Popup+:
- minor fixes git-svn-id: http://svn.miranda-ng.org/main/trunk@13019 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Popup')
-rw-r--r--plugins/Popup/src/common.h13
-rw-r--r--plugins/Popup/src/popup_wnd2.cpp18
-rw-r--r--plugins/Popup/src/services.cpp17
3 files changed, 20 insertions, 28 deletions
diff --git a/plugins/Popup/src/common.h b/plugins/Popup/src/common.h
index 6f0f1b8ab2..819d9fabe0 100644
--- a/plugins/Popup/src/common.h
+++ b/plugins/Popup/src/common.h
@@ -53,17 +53,8 @@ inline int Percentile2Byte(int vPerc) { return (vPerc * 255) / 100; }
//===== Strings & MirandaDB ==================
inline char *db_get_s(MCONTACT hContact, const char *ModuleName, const char *SettingName, const char *Default)
{
- DBVARIANT dbv;
- db_get(hContact, ModuleName, SettingName, &dbv);
-
- char *result = 0;
- if (dbv.type == DBVT_ASCIIZ)
- result = mir_strdup(dbv.pszVal);
- else if (Default)
- result = mir_strdup(Default);
-
- db_free(&dbv);
- return result;
+ char *result = db_get_sa(hContact, ModuleName, SettingName);
+ return result ? result : mir_strdup(Default);
}
inline INT_PTR DBGetContactSettingStringX(MCONTACT hContact, const char *ModuleName, const char *SettingName, const char *Default, const int retType)
diff --git a/plugins/Popup/src/popup_wnd2.cpp b/plugins/Popup/src/popup_wnd2.cpp
index 472de1de31..f041ecaf51 100644
--- a/plugins/Popup/src/popup_wnd2.cpp
+++ b/plugins/Popup/src/popup_wnd2.cpp
@@ -270,7 +270,6 @@ void PopupWnd2::update()
// render popup
m_bmpBase->allocate(m_sz.cx, m_sz.cy);
HDC hdc = m_bmpBase->getDC();
- if (!skin) return;
SetBkMode(hdc, TRANSPARENT);
skin->display(m_bmpBase, this, m_options,
PopupSkin::DF_STATIC);
@@ -1034,14 +1033,15 @@ LRESULT CALLBACK PopupWnd2::WindowProc(UINT message, WPARAM wParam, LPARAM lPara
(m_lptzTitle) ? m_lptzTitle : _T(""),
(m_lptzText) ? m_lptzText : _T(""));
- OpenClipboard(m_hwnd);
- EmptyClipboard();
- HGLOBAL clipbuffer = GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE, (tszText.GetLength() + 1) * sizeof(TCHAR));
- TCHAR *buffer = (TCHAR *)GlobalLock(clipbuffer);
- mir_tstrcpy(buffer, tszText);
- GlobalUnlock(clipbuffer);
- SetClipboardData(CF_UNICODETEXT, clipbuffer);
- CloseClipboard();
+ if (OpenClipboard(m_hwnd)) {
+ EmptyClipboard();
+ HGLOBAL clipbuffer = GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE, (tszText.GetLength() + 1) * sizeof(TCHAR));
+ TCHAR *buffer = (TCHAR *)GlobalLock(clipbuffer);
+ mir_tstrcpy(buffer, tszText);
+ GlobalUnlock(clipbuffer);
+ SetClipboardData(CF_UNICODETEXT, clipbuffer);
+ CloseClipboard();
+ }
}
PUDeletePopup(m_hwnd);
break;
diff --git a/plugins/Popup/src/services.cpp b/plugins/Popup/src/services.cpp
index 347193f96c..77fb4ea64f 100644
--- a/plugins/Popup/src/services.cpp
+++ b/plugins/Popup/src/services.cpp
@@ -381,12 +381,12 @@ INT_PTR Popup_RegisterPopupClass(WPARAM, LPARAM lParam)
FontIDT fid = { 0 };
fid.cbSize = sizeof(FontIDT);
mir_sntprintf(fid.group, SIZEOF(fid.group), _T(PU_FNT_AND_COLOR)_T("/%S"), ptd->pupClass.pszName);
- strncpy(fid.dbSettingsGroup, PU_MODULCLASS, SIZEOF(fid.dbSettingsGroup));
+ strncpy(fid.dbSettingsGroup, PU_MODULCLASS, SIZEOF(fid.dbSettingsGroup)-1);
fid.flags = FIDF_DEFAULTVALID;
fid.deffontsettings.charset = DEFAULT_CHARSET;
fid.deffontsettings.size = -11;
- _tcsncpy(fid.deffontsettings.szFace, _T("Verdana"), SIZEOF(fid.deffontsettings.szFace));
- _tcsncpy(fid.name, _T(PU_FNT_NAME_TEXT), SIZEOF(fid.name));
+ _tcsncpy(fid.deffontsettings.szFace, _T("Verdana"), SIZEOF(fid.deffontsettings.szFace)-1);
+ _tcsncpy(fid.name, _T(PU_FNT_NAME_TEXT), SIZEOF(fid.name)-1);
strncpy(fid.prefix, setting, SIZEOF(fid.prefix));
mir_snprintf(fid.prefix, SIZEOF(fid.prefix), "%s/Text", ptd->pupClass.pszName); // result is "%s/TextCol"
fid.deffontsettings.style = 0;
@@ -428,12 +428,10 @@ INT_PTR Popup_UnregisterPopupClass(WPARAM, LPARAM lParam)
//===== Popup/AddPopupClass (for core class api support)
INT_PTR Popup_CreateClassPopup(WPARAM wParam, LPARAM lParam) {
- INT_PTR ret = 1;
POPUPDATACLASS *pdc = (POPUPDATACLASS *)lParam;
- if (pdc->cbSize != sizeof(POPUPDATACLASS)) return ret;
-
- POPUPCLASS *pc = NULL;
+ if (!pdc || (pdc->cbSize != sizeof(POPUPDATACLASS))) return 1;
+ POPUPCLASS *pc;
if (wParam)
pc = (POPUPCLASS*)wParam;
else {
@@ -441,6 +439,9 @@ INT_PTR Popup_CreateClassPopup(WPARAM wParam, LPARAM lParam) {
POPUPTREEDATA *ptd = (POPUPTREEDATA *)FindTreeData(group, NULL, 2);
if (ptd)
pc = &ptd->pupClass;
+ else
+ pc = NULL;
+ mir_free(group);
}
if (pc) {
POPUPDATA2 ppd2 = { sizeof(ppd2) };
@@ -464,5 +465,5 @@ INT_PTR Popup_CreateClassPopup(WPARAM wParam, LPARAM lParam) {
return Popup_AddPopup2((WPARAM)&ppd2, pc->lParam);
}
- return ret != 0 ? 1 : 0;
+ return 1;
}